Skip to content

regrtest --single-process-per-case selects the wrong tests for some case ids #163034

Backlog

Description

@fedonman

Bug description:

python -m test --single-process-per-case (GH-151689, gh-109817) selects each case in its worker by passing the case id as a -m pattern. A case id containing brackets, such as the ZoneInfoTest[<zone>] cases of test_datetime, is read as an fnmatch character class, so its worker runs no test and the run still reports SUCCESS. A case id without a dot, such as the module doctest statistics in test_statistics, matches every id with that component, so its worker also runs the other doctests of that module.

tests/test_ids.py:

import doctest, unittest

class Tests(unittest.TestCase):
    def test_one(self): pass

Bracketed = type('Tests[x]', (Tests,), {})

def load_tests(loader, tests, ignore):
    for name in 'example', 'example.a', 'example.b':
        test = doctest.DocTestParser().get_doctest('>>> 1\n1\n', {}, name, None, 0)
        tests.addTest(doctest.DocTestCase(test))
    return tests
$ python -m test --testdir tests --single-process-per-case test_ids
Using random seed: 3110927847
0:00:00 load avg: 1.09 mem:   25.3 MiB Run 5 tests in parallel using 1 worker process
0:00:00 load avg: 1.09 mem:   27.3 MiB [1/5] test_ids.Tests[x].test_one ran no tests
0:00:00 load avg: 1.09 mem:   27.4 MiB [2/5] test_ids.Tests.test_one passed
0:00:00 load avg: 1.09 mem:   27.5 MiB [3/5] example passed
0:00:00 load avg: 1.09 mem:   27.1 MiB [4/5] example.a passed
0:00:01 load avg: 1.09 mem:   25.7 MiB [5/5] example.b passed

== Tests result: SUCCESS ==

1 test run no tests:
    test_ids.Tests[x].test_one

All 4 tests OK.

Total duration: 1.1 sec
Total tests: run=6
Total test files: run=5/5 run_no_tests=1
Result: SUCCESS

Expected: each of the 5 cases runs once in its own process, as the option promises ("run each test case in its own process"), so All 5 tests OK. and run=5.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

  1. added
    tests
    type-bug
    on Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    teststype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions