我有以下测试用例
from rest_framework.test import APIClient
from django.test import TestCase
from factories import UserFactory
class TestUserApi(TestCase):
def setUp(self):
# Create or get model factory objects
self.users = UserFactory()
self.client = APIClient()
def test_user_list(self):
response = self.client.get('/api/1/users/')
self.assertEqual(response.status_code, status.HTTP_200_OK)
def tearDown(self):
pass
当我运行上述测试用例时,我收到以下错误,我不明白为什么?
ERROR: test_user_list (test_cases.TestUserApi)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/test/testcases.py", line 178, in __call__
self._pre_setup()
File "/usr/local/lib/python2.7/dist-packages/django/test/testcases.py", line 749, in _pre_setup
self._fixture_setup()
File "/usr/local/lib/python2.7/dist-packages/django/test/testcases.py", line 861, in _fixture_setup
if not connections_support_transactions():
File "/usr/local/lib/python2.7/dist-packages/django/test/testcases.py", line 848, in connections_support_transactions
for conn in connections.all())
File "/usr/local/lib/python2.7/dist-packages/django/test/testcases.py", line 848, in <genexpr>
for conn in connections.all())
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 49, in __get__
res = instance.__dict__[self.func.__name__] = self.func(instance)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 676, in supports_transactions
self.connection.leave_transaction_management()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 324, in leave_transaction_management
if managed == self.get_autocommit():
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 331, in get_autocommit
self.ensure_connection()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 114, in connect
conn_params = self.get_connection_params()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 86, in get_connection_params
raise NotImplementedError
NotImplementedError:
修改
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'integration_tests',
'USER': 'root',
'PASSWORD': 'root',
'HOST': '192.16x.xx.x',
'PORT': '3306',
},
}