Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FastFixtureTestCase and Django 1.6 #162

Open
fertringer opened this issue May 30, 2014 · 2 comments
Open

FastFixtureTestCase and Django 1.6 #162

fertringer opened this issue May 30, 2014 · 2 comments

Comments

@fertringer
Copy link

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?

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:

from django.db import transaction

@transaction.atomic
def function():
    return True

Testing this will trigger the same error.

@Ry4an
Copy link

Ry4an commented Nov 21, 2014

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?

Thanks!

@jwhitlock
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants