Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#14975 closed (fixed)

TransactionTestCases are broken by django.contrib.auth in 1.2.4

Reported by: rpbarlow Owned by: nobody
Component: Testing framework Version: 1.2
Severity: Keywords: blocker, regression
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


I tried to upgrade my project to 1.2.4, and found that my TransactionTestCases were failing. I discovered that they would pass by themselves, but they would fail if I ran the django.contrib.auth tests first.

I made a very simple Django project that has an app with a single TransactionTestCase. It runs a self.assertTrue(True). If you run the testapp test by itself, it will pass, but if you run the auth tests first, it will fail in this way:

ERROR: test_test (testapp.tests.SimpleTest)
Traceback (most recent call last):
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/test/", line 257, in __call__
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/test/", line 224, in _pre_setup
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/test/", line 236, in _fixture_setup
    call_command('flush', verbosity=0, interactive=False, database=db)
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/core/management/", line 166, in call_command
    return klass.execute(*args, **defaults)
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/core/management/", line 220, in execute
    output = self.handle(*args, **options)
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/core/management/", line 351, in handle
    return self.handle_noargs(**options)
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/core/management/commands/", line 75, in handle_noargs
    emit_post_sync_signal(all_models, verbosity, interactive, db)
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/core/management/", line 182, in emit_post_sync_signal
    interactive=interactive, db=db)
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/dispatch/", line 172, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/contrib/auth/management/", line 28, in create_permissions
    defaults={'name': name, 'content_type': ctype})
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/db/models/", line 135, in get_or_create
    return self.get_query_set().get_or_create(**kwargs)
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/db/models/", line 383, in get_or_create
    transaction.savepoint_rollback(sid, using=self.db)
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/db/", line 242, in savepoint_rollback
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/db/backends/", line 61, in _savepoint_rollback
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/db/backends/postgresql_psycopg2/", line 44, in execute
    return self.cursor.execute(query, args)
DatabaseError: no such savepoint

I put this into the Testing framework component, but it may be more appropriate in the Authentication component.

Django rocks, thanks for working on it!

Attachments (1)

test_project.tar.bz2 (3.3 KB) - added by rpbarlow 6 years ago.
A small Django project that demonstrates the issue

Download all attachments as: .zip

Change History (12)

Changed 6 years ago by rpbarlow

A small Django project that demonstrates the issue

comment:1 Changed 6 years ago by pmclanahan

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

I am having the same issue. We're using the MySQL db backend.

comment:2 Changed 6 years ago by russellm

  • milestone set to 1.3

Further narrowing -- you can get the failure by just running auth.BackendTest.test_custom_perms before your TransactionTestCase, but only on the 1.2 branch. trunk seems to be unaffected.

This is disturbingly similar to #14925, but I don't think it's *exactly* the same bug, so I'll leave this open for the moment. Regardless, it's a blocker for 1.3.

comment:3 Changed 6 years ago by russellm

  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 6 years ago by rpbarlow

Hi russellm! May I request that a 1.2.5 release be made with a fix for this issue? Since 1.2.4 was a security release, I'd really like to be able to use it for my project, but I can't test it to verify that my application is working properly. If a 1.2.5 release were made, I'd be able to get the 1.2.4 security updates sooner.

comment:5 Changed 6 years ago by russellm

There will definitely be a 1.2.5 release -- it's just a matter of timing. When we release 1.3 final (currently scheduled for the end of the month), we will also release 1.2.5.

The question is whether we need to do an interim 1.2.5 release, and then release 1.2.6 when 1.3 happens. As a result of my triage binge last week, I noticed a couple of regressions that have emerged on 1.2.4, so an interim release may be warranted.

comment:6 Changed 6 years ago by russellm

  • Keywords blocker regression added

comment:7 Changed 6 years ago by mkelley33 <michauxkelley@…>

+1 for getting it into 1.2.5 Thanks rpbarlow and russellm!

comment:8 Changed 6 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(In [15192]) Fixed #14975, #14925 -- Added some cache flushing to avoid some cross-test effects. Thanks to jsdalton and rpbarlow for the reports.

comment:9 Changed 6 years ago by russellm

(In [15193]) [1.2.X] Fixed #14975, #14925 -- Added some cache flushing to avoid some cross-test effects. Thanks to jsdalton and rpbarlow for the reports.

Backport of r15192 from trunk.

comment:10 Changed 6 years ago by rpbarlow

Sweet, thanks for the fix!

comment:11 Changed 5 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top