Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#14975 closed (fixed)

TransactionTestCases are broken by django.contrib.auth in 1.2.4

Reported by: Randy Barlow 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: no UI/UX: no

Description

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/testcases.py", line 257, in __call__
    self._pre_setup()
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/test/testcases.py", line 224, in _pre_setup
    self._fixture_setup()
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/test/testcases.py", 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/__init__.py", line 166, in call_command
    return klass.execute(*args, **defaults)
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/core/management/commands/flush.py", 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/sql.py", line 182, in emit_post_sync_signal
    interactive=interactive, db=db)
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/dispatch/dispatcher.py", 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/__init__.py", 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/manager.py", 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/query.py", 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/transaction.py", line 242, in savepoint_rollback
    connection._savepoint_rollback(sid)
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/db/backends/__init__.py", line 61, in _savepoint_rollback
    self.cursor().execute(self.ops.savepoint_rollback_sql(sid))
  File "/home/rbarlow/.virtualenvs/titles-db/lib/python2.6/site-packages/django/db/backends/postgresql_psycopg2/base.py", 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 Randy Barlow 13 years ago.
A small Django project that demonstrates the issue

Download all attachments as: .zip

Change History (12)

by Randy Barlow, 13 years ago

Attachment: test_project.tar.bz2 added

A small Django project that demonstrates the issue

comment:1 by Paul McLanahan, 13 years ago

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

comment:2 by Russell Keith-Magee, 13 years ago

milestone: 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 by Russell Keith-Magee, 13 years ago

Triage Stage: UnreviewedAccepted

comment:4 by Randy Barlow, 13 years ago

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 by Russell Keith-Magee, 13 years ago

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 by Russell Keith-Magee, 13 years ago

Keywords: blocker regression added

comment:7 by mkelley33 <michauxkelley@…>, 13 years ago

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

comment:8 by Russell Keith-Magee, 13 years ago

Resolution: fixed
Status: newclosed

(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 by Russell Keith-Magee, 13 years ago

(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 by Randy Barlow, 13 years ago

Sweet, thanks for the fix!

comment:11 by Jacob, 12 years ago

milestone: 1.3

Milestone 1.3 deleted

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