Skip to content

[3.13] gh-152548: Add a test.support.isolation.runInSubprocess() decorator (GH-152551) - #154784

Open
serhiy-storchaka wants to merge 1 commit into
python:3.13from
serhiy-storchaka:backport-bde526d-3.13
Open

[3.13] gh-152548: Add a test.support.isolation.runInSubprocess() decorator (GH-152551)#154784
serhiy-storchaka wants to merge 1 commit into
python:3.13from
serhiy-storchaka:backport-bde526d-3.13

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Manual backport of GH-152551 to 3.13; miss-islington could not do it automatically.

The only conflict was in Lib/test/test_support.py: 3.13 has neither TestHashlibSupport nor its hashlib_helper import, so the appended TestIsolated class had no matching context and that unrelated class was swept into the conflict. Only the isolation import and TestIsolated are taken here; everything else is identical to what landed in main.

Verified against a 3.13 build: test_support passes, with all nine TestIsolated tests running.

(cherry picked from commit bde526d)

Co-authored-by: Serhiy Storchaka storchaka@gmail.com

…ator (pythonGH-152551)

Run a test in a fresh interpreter subprocess, so that it does not share global
or interpreter state with the rest of the test run.  It can decorate a test
method (only that method runs in a subprocess) or a TestCase subclass (the
whole class runs in one subprocess, with its setUpClass()/setUp()/tearDown()/
tearDownClass() running there rather than in the parent).

Failures, errors and skips, including those of individual subtests, are
reported for the test; a failure or an error shows the original subprocess
traceback.  The subprocess inherits the parent's resource, memory, verbosity
and failfast configuration, so that requires_resource(), bigmemtest() and
similar behave the same in both processes.  A decorated test is skipped where
subprocesses are unavailable, since it must spawn one.

The test.support.isolation.runningInSubprocess flag is true in the subprocess,
so that fixtures can choose what to run there.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit bde526d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant