Opened 13 years ago

Closed 13 years ago

#17377 closed Bug (fixed)

Test admin_views.UserAdminTest.test_user_permission_performance depends on side effects

Reported by: Gregor Müllegger Owned by: nobody
Component: Uncategorized Version: dev
Severity: Normal Keywords: test sideeffect
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The test admin_views.UserAdminTest.test_user_permission_performance fails if it's run on its own. If run in conjunction with other tests, it gets a cache hit for looking up a content type. When run on it's own it needs to look that up, causing more queries than expected.

gregor@layka ~/projects/gsoc/django/tests (git)-[master] % PYTHONPATH=.. ./runtests.py --settings=test_sqlite admin_views.UserAdminTest.test_user_permission_performance
Creating test database for alias 'default'...
Creating test database for alias 'other'...
F
======================================================================
FAIL: test_user_permission_performance (regressiontests.admin_views.tests.UserAdminTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/gregor/projects/gsoc/django/tests/regressiontests/admin_views/tests.py", line 2987, in test_user_permission_performance
    self.assertEqual(response.status_code, 200)
  File "/home/gregor/projects/gsoc/django/django/test/testcases.py", line 246, in __exit__
    executed, self.num
AssertionError: 8 queries executed, 7 expected

----------------------------------------------------------------------
Ran 1 test in 0.237s

FAILED (failures=1)
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...
1 gregor@layka ~/projects/gsoc/django/tests (git)-[master] % PYTHONPATH=.. ./runtests.py --settings=test_sqlite admin_views.UserAdminTest                                
Creating test database for alias 'default'...
Creating test database for alias 'other'...
......
----------------------------------------------------------------------
Ran 6 tests in 0.718s

OK
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...
gregor@layka ~/projects/gsoc/django/tests (git)-[master] % PYTHONPATH=.. ./runtests.py --settings=test_sqlite admin_views.UserAdminTest.test_user_permission_performance
Creating test database for alias 'default'...
Creating test database for alias 'other'...
F
======================================================================
FAIL: test_user_permission_performance (regressiontests.admin_views.tests.UserAdminTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/gregor/projects/gsoc/django/tests/regressiontests/admin_views/tests.py", line 2987, in test_user_permission_performance
    self.assertEqual(response.status_code, 200)
  File "/home/gregor/projects/gsoc/django/django/test/testcases.py", line 246, in __exit__
    executed, self.num
AssertionError: 8 queries executed, 7 expected

----------------------------------------------------------------------
Ran 1 test in 0.228s

FAILED (failures=1)
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...

Attachments (1)

issue17377.1.patch (632 bytes ) - added by Gregor Müllegger 13 years ago.
Patch. https://github.com/gregmuellegger/django/tree/issue17377

Download all attachments as: .zip

Change History (3)

comment:1 by Gregor Müllegger, 13 years ago

Has patch: set

comment:2 by Aymeric Augustin, 13 years ago

Resolution: fixed
Status: newclosed

In [17199]:

Fixed #17377 -- Don't depend on a warm cache in admin_views.UserAdminTest.test_user_permission_performance. Thanks Gregor Müllegger.

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