8000 bpo-43425: Update test_c_parser not to use TempdirManager (GH-26693) · python/cpython@736ed6f · GitHub
[go: up one dir, main page]

Skip to content

Commit 736ed6f

Browse files
authored
bpo-43425: Update test_c_parser not to use TempdirManager (GH-26693)
1 parent cb7230c commit 736ed6f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Lib/test/test_peg_generator/test_c_parser.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import sysconfig
22
import textwrap
33
import unittest
4-
from distutils.tests.support import TempdirManager
4+
import os
5+
import shutil
6+
import tempfile
57
from pathlib import Path
68

79
from test import test_tools
@@ -68,20 +70,21 @@ def test_parse(self):
6870
"""
6971

7072

71-
class TestCParser(TempdirManager, unittest.TestCase):
73+
class TestCParser(unittest.TestCase):
7274
def setUp(self):
7375
self._backup_config_vars = dict(sysconfig._CONFIG_VARS)
7476
cmd = support.missing_compiler_executable()
7577
if cmd is not None:
7678
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()
7981
change_cwd = os_helper.change_cwd(self.tmp_path)
8082
change_cwd.__enter__()
8183
self.addCleanup(change_cwd.__exit__, None, None, None)
8284

8385
def tearDown(self):
84-
super(TestCParser, self).tearDown()
86+
os.chdir(self.old_cwd)
87+
shutil.rmtree(self.tmp_path)
8588
sysconfig._CONFIG_VARS.clear()
8689
sysconfig._CONFIG_VARS.update(self._backup_config_vars)
8790

0 commit comments

Comments
 (0)
0