bpo-43425: Update test_c_parser not to use TempdirManager (GH-26693) · python/cpython@736ed6f (original) (raw)
File tree
1 file changed
lines changed
- Lib/test/test_peg_generator
1 file changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
1 | 1 | import sysconfig |
2 | 2 | import textwrap |
3 | 3 | import unittest |
4 | -from distutils.tests.support import TempdirManager | |
4 | +import os | |
5 | +import shutil | |
6 | +import tempfile | |
5 | 7 | from pathlib import Path |
6 | 8 | |
7 | 9 | from test import test_tools |
@@ -68,20 +70,21 @@ def test_parse(self): | ||
68 | 70 | """ |
69 | 71 | |
70 | 72 | |
71 | -class TestCParser(TempdirManager, unittest.TestCase): | |
73 | +class TestCParser(unittest.TestCase): | |
72 | 74 | def setUp(self): |
73 | 75 | self._backup_config_vars = dict(sysconfig._CONFIG_VARS) |
74 | 76 | cmd = support.missing_compiler_executable() |
75 | 77 | if cmd is not None: |
76 | 78 | self.skipTest("The %r command is not found" % cmd) |
77 | -super(TestCParser, self).setUp() | |
78 | -self.tmp_path = self.mkdtemp() | |
79 | +self.old_cwd = os.getcwd() | |
80 | +self.tmp_path = tempfile.mkdtemp() | |
79 | 81 | change_cwd = os_helper.change_cwd(self.tmp_path) |
80 | 82 | change_cwd.__enter__() |
81 | 83 | self.addCleanup(change_cwd.__exit__, None, None, None) |
82 | 84 | |
83 | 85 | def tearDown(self): |
84 | -super(TestCParser, self).tearDown() | |
86 | +os.chdir(self.old_cwd) | |
87 | +shutil.rmtree(self.tmp_path) | |
85 | 88 | sysconfig._CONFIG_VARS.clear() |
86 | 89 | sysconfig._CONFIG_VARS.update(self._backup_config_vars) |
87 | 90 |