gh-152548: Convert the test_signal wakeup tests to @isolated()#152639
Open
serhiy-storchaka wants to merge 5 commits into
Open
gh-152548: Convert the test_signal wakeup tests to @isolated()#152639serhiy-storchaka wants to merge 5 commits into
serhiy-storchaka wants to merge 5 commits into
Conversation
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 once there). Failures, errors and skips, including those of individual subtests, are reported for the test and show the original subprocess traceback. The subprocess inherits the parent's resource, memory and verbosity configuration, so that requires_resource(), bigmemtest() and similar behave the same in both processes. The test.support.running_isolated 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>
Fixes the ruff F401 "imported but unused" lint failure for the re-exports. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@isolated() always runs the test in a subprocess, so skip it in the parent process on platforms that lack subprocess support, the same way the tests it replaces were guarded by requires_subprocess(). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Move the helper into a public test.support.isolation submodule (used as "from test.support import isolation"), drop the test.support re-export, and document running_isolated and isolated() under that module. Replay expected failures and forward subprocess durations to the parent, so an @expectedfailure isolated test is no longer misreported as an unexpected success and reported timings reflect the subprocess run. Add test.test_support.TestIsolated covering the outcomes, subtest reporting, traceback-as-cause, duration forwarding and the no-subprocess skip. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
WakeupSignalTests and WakeupSocketSignalTests ran each test as a script
string via assert_python_ok('-c', ...), using a subprocess to have a
single thread for signal delivery. Decorate them with @isolated()
instead, so the same code runs as a normal method body using self.assert*.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Documentation build overview
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The wakeup tests in
WakeupSignalTestsandWakeupSocketSignalTestsneed a process with no background thread so that signals are delivered to the main thread. Each was driven as a hand-written script string run in a child process viaassert_python_ok('-c', ...), signalling failures with bareraiseand reported to the runner only through the child exit code.With
@isolation.isolated()the same code runs as a normal method body in a fresh subprocess, usingself.assert*and reported per test, with the subprocess traceback shown as the cause of a failure. Thecheck_wakeup()helper becomes an ordinary helper that runs atest(read)callback in-process and asserts the read-back; the_testcapiskips move to the parent process (so no subprocess is spawned when skipped).This is built on top of #152551 (the
test.support.isolationsubmodule). The first four commits belong to that PR and will drop out once it is merged and this branch is rebased.