summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 176ff10..ad89864 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -1399,15 +1399,23 @@ class ProcessTestCaseNoPoll(ProcessTestCase):
@unittest.skipUnless(getattr(subprocess, '_posixsubprocess', False),
"_posixsubprocess extension module not found.")
class ProcessTestCasePOSIXPurePython(ProcessTestCase, POSIXProcessTestCase):
- def setUp(self):
- subprocess._posixsubprocess = None
- ProcessTestCase.setUp(self)
- POSIXProcessTestCase.setUp(self)
-
- def tearDown(self):
- subprocess._posixsubprocess = sys.modules['_posixsubprocess']
- POSIXProcessTestCase.tearDown(self)
- ProcessTestCase.tearDown(self)
+ @classmethod
+ def setUpClass(cls):
+ global subprocess
+ assert subprocess._posixsubprocess
+ # Reimport subprocess while forcing _posixsubprocess to not exist.
+ with support.check_warnings(('.*_posixsubprocess .* not being used.*',
+ RuntimeWarning)):
+ subprocess = support.import_fresh_module(
+ 'subprocess', blocked=['_posixsubprocess'])
+ assert not subprocess._posixsubprocess
+
+ @classmethod
+ def tearDownClass(cls):
+ global subprocess
+ # Reimport subprocess as it should be, restoring order to the universe.
+ subprocess = support.import_fresh_module('subprocess')
+ assert subprocess._posixsubprocess
class HelperFunctionTests(unittest.TestCase):