You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Doing some testing of our Django 1.5.4 project to see if we can upgrade to Django 1.6, and I am running into this error when running unit tests:
TransactionManagementError: Your database backend doesn't behave properly when autocommit is off. Turn it on before using 'atomic'.
I am running django-nose 1.2, with a sqllite database for unit tests.
Digging into this, it seems like FastFixtureTestCase code is doing some direct transaction management, to save time on fixture loading(which is the point), but it does not seem compatible with Django 1.6's new transaction management.
From what I can see, the problem starts in my code with a "get_or_create", and then there is a atomic block that Django is trying to execute to resolve this, which throws the error because (I am assuming) FastFixtureTestCase has set transaction management to be enabled?
You don't even need to add any fixtures (which we do have on the real tests), and the error will trigger when you run ./manage.py test
I'm going to try and mock out get_or_create but I'd rather not do that everywhere in my code base as it is quite large, and we use that function in several place, so any help would be appreciated.
edit:
More fundamentally it looks like an issue with any code inside an atomic block when using FastFixtureTestCase, even something like:
I know this is old, but I'm having exactly the same problem when using SQLlite and django1.7. I see that since this issue was created there are plenty of commits and issues talking about using django-nose with django-1.7 and what will become django-1.8.
How are people continuing to use django-nose with django-1.6+? Are you not using FastFixtureTestCase? Not using sqlite? Not doing any db writes in tests?
We've dropped support for Django 1.6, but I imagine there are still problems (see bug #193). I've made quite a few changes to the project, including adding some basic database tests, but not using FastFixtureTestCase yet. Does someone want to update testapp/tests.py with a new testcase using FastFixtureTestCase that reproduces this issue?
Doing some testing of our Django 1.5.4 project to see if we can upgrade to Django 1.6, and I am running into this error when running unit tests:
I am running django-nose 1.2, with a sqllite database for unit tests.
Digging into this, it seems like FastFixtureTestCase code is doing some direct transaction management, to save time on fixture loading(which is the point), but it does not seem compatible with Django 1.6's new transaction management.
From what I can see, the problem starts in my code with a "get_or_create", and then there is a atomic block that Django is trying to execute to resolve this, which throws the error because (I am assuming) FastFixtureTestCase has set transaction management to be enabled?
This is easy to duplicate, I setup a quick project which demonstrates the issue here:
https://github.com/fertringer/django-nose-possible-bug-1.6.git
You don't even need to add any fixtures (which we do have on the real tests), and the error will trigger when you run ./manage.py test
I'm going to try and mock out get_or_create but I'd rather not do that everywhere in my code base as it is quite large, and we use that function in several place, so any help would be appreciated.
edit:
More fundamentally it looks like an issue with any code inside an atomic block when using FastFixtureTestCase, even something like:
Testing this will trigger the same error.
The text was updated successfully, but these errors were encountered: