Opened 3 years ago

Closed 3 years ago

#32808 closed Bug (fixed)

DiscoverRunner.build_suite() does not restore self.test_loader.testNamePatterns

Reported by: Chris Jerdonek Owned by: Mariusz Felisiak
Component: Testing framework Version: 3.2
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

DiscoverRunner.build_suite() does not restore self.test_loader.testNamePatterns after setting it in this line:
https://github.com/django/django/blob/e703b152c6148ddda1b072a4353e9a41dca87f90/django/test/runner.py#L639

I noticed this issue when finding a test isolation issue while working on #24522. The test test_runner.test_discover_runner.DiscoverRunnerTests.test_name_patterns passes test_name_patterns to DiscoverRunner:
https://github.com/django/django/blob/e703b152c6148ddda1b072a4353e9a41dca87f90/tests/test_runner/test_discover_runner.py#L119-L122

And this causes some later tests to fail.

Change History (5)

comment:1 by Mariusz Felisiak, 3 years ago

Triage Stage: UnreviewedAccepted

Good catch! A minimal set of tests to reproduce:

./runtests.py test_runner.test_discover_runner.DiscoverRunnerTests.test_name_patterns test_runner.tests.TestSuiteTests --parallel=1

comment:2 by Chris Jerdonek, 3 years ago

Thanks! Yes, or even smaller--

$ ./runtests.py test_runner.test_discover_runner.DiscoverRunnerTests.test_name_patterns test_runner.tests.TestSuiteTests.test_iter_test_cases_mixed_test_suite_classes

comment:3 by Mariusz Felisiak, 3 years ago

Owner: changed from nobody to Mariusz Felisiak
Status: newassigned

comment:4 by Mariusz Felisiak, 3 years ago

Has patch: set

comment:5 by GitHub <noreply@…>, 3 years ago

Resolution: fixed
Status: assignedclosed

In 62e8f369:

Fixed #32808 -- Prevented DiscoverRunner.build_suite() from mutating test loader patterns.

Thanks Chris Jerdonek for the report and reviews.

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