I am on Django 1.6, writing a unit test using the built-in client, trying to test a login call. The code below summarizes it. This is run against SQLite3 database. When I run this, I get the following error when the self.client.login() method is called:
TransactionManagementError: Your database backend doesn't behave properly when autocommit is off. Turn it on before using 'atomic'.
It tried to set:
'OPTIONS': {
'autocommit': True,
}
in the database section of my settings.py file, but that didn't help and generated a different error message:
KeyError: 'ENGINE'
Any help with this would be greatly appreciated. My code follows:
def testShouldRedirectToDashboardAfterSuccessfulLogin(self):
from django.contrib.auth.models import User
u = User.objects.create_user(
username="a@b.cz",
password='aaaaa',
email="a@b.cz"
)
self.assertTrue(self.client.login(
username='a@b.cz',
password='aaaaa'
))