Opened 10 years ago
Closed 10 years ago
#25110 closed Bug (fixed)
A test in test_runner fails in isolation
| Reported by: | Yosuke Yasuda | Owned by: | Joseph Gordon |
|---|---|---|---|
| Component: | Testing framework | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Joseph Gordon | Triage Stage: | Ready for checkin |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I run tests with Python 3.4.3 but failed like this.
% ./runtests.py ./test_runner
Testing against Django installed in '/Users/yasudayousuke/oss_hack/django_dev/django_parent/django'
Creating test database for alias 'default'...
Creating test database for alias 'other'...
.....F...........ss.......................
======================================================================
FAIL: test_duplicates_ignored (test_runner.test_discover_runner.DiscoverRunnerTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/yasudayousuke/oss_hack/django_dev/django_parent/tests/test_runner/test_discover_runner.py", line 133, in test_duplicates_ignored
self.assertEqual(single, dups)
AssertionError: 259 != 260
----------------------------------------------------------------------
Ran 42 tests in 4.421s
FAILED (failures=1, skipped=2)
Destroying test database for alias 'default'...
Destroying test database for alias 'other'...
Change History (10)
comment:1 by , 10 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 10 years ago
| Cc: | added |
|---|---|
| Owner: | changed from to |
| Status: | new → assigned |
comment:3 by , 10 years ago
I think I've at least identified the issue. When test_discover_runner is run and gis_tests is not in current test labels, the discovery process inside the test fails with the error:
RuntimeError: Model class gis_tests.geo3d.models.City3D doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded.
Then that discovery result is not considered as duplicate, hence the test failure.
I don't know right now what's the best resolution would be, apart from recreating an embedded app structure inside test_runner or in a ../test_discovery_sample-like dir, which might be overkill just for that test.
comment:4 by , 10 years ago
Maybe with that patch:
-
tests/test_runner/test_discover_runner.py
diff --git a/tests/test_runner/test_discover_runner.py b/tests/test_runner/test_discover_runner.py index 70117f0..4a3613e 100644
a b class DiscoverRunnerTest(TestCase): 121 121 """ 122 122 Tests shouldn't be discovered twice when discovering on overlapping paths. 123 123 """ 124 single = DiscoverRunner().build_suite(["gis_tests"]).countTestCases() 125 dups = DiscoverRunner().build_suite( 126 ["gis_tests", "gis_tests.geo3d"]).countTestCases() 124 with self.modify_settings(INSTALLED_APPS={'append': 'gis_tests.geo3d'}): 125 suite = DiscoverRunner().build_suite(["gis_tests.geo3d", "gis_tests.geo3d"]) 126 single = DiscoverRunner().build_suite(["gis_tests"]).countTestCases() 127 dups = DiscoverRunner().build_suite( 128 ["gis_tests", "gis_tests.geo3d"]).countTestCases() 127 129 self.assertEqual(single, dups) 128 130 129 131 def test_reverse(self):
Joseph, still interested to test that and cook a patch?
comment:6 by , 10 years ago
Looks like it fixed the assertion error. Is the next step to create a pull request (this is my first time interacting with the Django project)?
comment:9 by , 10 years ago
| Summary: | A test in test_runner fails → A test in test_runner fails in isolation |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
Bisected to ad0be620aece4dde2f94383426c284f4afef9fbc