Code

Opened 4 years ago

Closed 3 years ago

Last modified 3 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:

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 rpbarlow 4 years ago.
A small Django project that demonstrates the issue

Download all attachments as: .zip

Change History (12)

Changed 4 years ago by rpbarlow

A small Django project that demonstrates the issue

comment:1 Changed 4 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 4 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 4 years ago by russellm

  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 4 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 4 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 4 years ago by russellm

  • Keywords blocker, regression added

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

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

comment:8 Changed 3 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 3 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 3 years ago by rpbarlow

Sweet, thanks for the fix!

comment:11 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.