Opened 9 years ago

Closed 9 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 Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Joseph Gordon, 9 years ago

Cc: Joseph Gordon added
Owner: changed from nobody to Joseph Gordon
Status: newassigned

comment:3 by Claude Paroz, 9 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 Claude Paroz, 9 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):  
    121121        """
    122122        Tests shouldn't be discovered twice when discovering on overlapping paths.
    123123        """
    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()
    127129        self.assertEqual(single, dups)
    128130
    129131    def test_reverse(self):

Joseph, still interested to test that and cook a patch?

comment:5 by Joseph Gordon, 9 years ago

Yes, still interested. I'll test it out.

comment:6 by Joseph Gordon, 9 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:7 by Claude Paroz, 9 years ago

Yes, please.

comment:9 by Tim Graham, 9 years ago

Summary: A test in test_runner failsA test in test_runner fails in isolation
Triage Stage: AcceptedReady for checkin

comment:10 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 199a02d1:

Fixed #25110 -- Fixed a test_runner test isolation regression.

Thanks claudep for the patch.

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