#23947 closed Cleanup/optimization (fixed)
Django's test suite does not pass in reverse order
Reported by: | Tim Graham | Owned by: | Diego Guimarães |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | diegaogs@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
runtests.py
now has a --reverse
flag to run tests in reverse order (#23742). Unfortunately, Django's test suite doesn't pass this way which means some tests have side effects. We should see if we can fix this.
Attachments (2)
Change History (23)
comment:1 Changed 9 years ago by
Cc: | diegaogs@… added |
---|---|
Owner: | changed from nobody to Diego Guimarães |
Status: | new → assigned |
Changed 9 years ago by
Attachment: | 23947.diff added |
---|
comment:2 Changed 9 years ago by
Has patch: | set |
---|---|
Patch needs improvement: | set |
This initial patch fixes most of the errors when running the Django test suite with --reverse
. The common problems I've found so far, was basically that some tests were performing operations that in a reverse way triggered side effects, like a smtp sever that was stopped first and had issues with Thread when tried to start it again, and cache that was closed by a previous test, etc.
There is still one test failing with issues handling staticfiles cache.
FAIL: test_template_tag_denorm (staticfiles_tests.tests.TestCollectionCachedStorage) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/diego/djangoproject/django/tests/staticfiles_tests/tests.py", line 526, in test_template_tag_denorm self.assertIn(b'url("img/relative.acae32e4532b.png', content) AssertionError: 'url("img/relative.acae32e4532b.png' not found in '@import url("../cached/styles.bb84a0240107.css");\nbody {\n background: #d3d6d8 url("img/relative.deploy12345.png");\n}\n'
To reproduce this error: ./runtests.py --reverse staticfiles_tests.tests
comment:3 Changed 9 years ago by
I saw your paste in IRC that you had a proposed fix for the last issue. Any chance you could make a pull request with the fixes? That makes review a lot easier. Thanks!
Changed 9 years ago by
Attachment: | static_files.diff added |
---|
comment:11 Changed 9 years ago by
This new patch tries to solve the staticfiles test problem. I added a tearDown to the TestHashedFiles mixin, where it clears the hashed_files after each test, avoiding side effects and unexpected changes among them. Is this approach valid?
comment:13 Changed 9 years ago by
Has patch: | unset |
---|---|
Patch needs improvement: | unset |
SQLite is passing in reverse, but it looks like there is more work to do on PostgreSQL. I see the following failures:
admin_views.tests.AdminViewDeletedObjectsTest.test_generic_relations generic_relations_regress.tests.GenericRelationTests.test_annotate migrations.test_operations.OperationTests.test_alter_field_m2m queries.tests.SubqueryTests.test_related_sliced_subquery
comment:14 Changed 9 years ago by
Ok, I'll setup the test suite to run with PostgresSQL and debug those tests.
comment:15 Changed 9 years ago by
Created a new PR with the fixes to PostgreSQL https://github.com/django/django/pull/3726
comment:16 Changed 9 years ago by
Has patch: | set |
---|
comment:20 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I think we're finished here for now. Thanks Diego!
initial patch