mirror of
https://github.com/python/cpython.git
synced 2025-12-08 02:08:20 +00:00
bpo-43425: Update test_c_parser not to use TempdirManager (GH-26693)
This commit is contained in:
parent
cb7230c7a7
commit
736ed6f7a9
1 changed files with 8 additions and 5 deletions
|
|
@ -1,7 +1,9 @@
|
||||||
import sysconfig
|
import sysconfig
|
||||||
import textwrap
|
import textwrap
|
||||||
import unittest
|
import unittest
|
||||||
from distutils.tests.support import TempdirManager
|
import os
|
||||||
|
import shutil
|
||||||
|
import tempfile
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from test import test_tools
|
from test import test_tools
|
||||||
|
|
@ -68,20 +70,21 @@ unittest.main()
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class TestCParser(TempdirManager, unittest.TestCase):
|
class TestCParser(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self._backup_config_vars = dict(sysconfig._CONFIG_VARS)
|
self._backup_config_vars = dict(sysconfig._CONFIG_VARS)
|
||||||
cmd = support.missing_compiler_executable()
|
cmd = support.missing_compiler_executable()
|
||||||
if cmd is not None:
|
if cmd is not None:
|
||||||
self.skipTest("The %r command is not found" % cmd)
|
self.skipTest("The %r command is not found" % cmd)
|
||||||
super(TestCParser, self).setUp()
|
self.old_cwd = os.getcwd()
|
||||||
self.tmp_path = self.mkdtemp()
|
self.tmp_path = tempfile.mkdtemp()
|
||||||
change_cwd = os_helper.change_cwd(self.tmp_path)
|
change_cwd = os_helper.change_cwd(self.tmp_path)
|
||||||
change_cwd.__enter__()
|
change_cwd.__enter__()
|
||||||
self.addCleanup(change_cwd.__exit__, None, None, None)
|
self.addCleanup(change_cwd.__exit__, None, None, None)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(TestCParser, self).tearDown()
|
os.chdir(self.old_cwd)
|
||||||
|
shutil.rmtree(self.tmp_path)
|
||||||
sysconfig._CONFIG_VARS.clear()
|
sysconfig._CONFIG_VARS.clear()
|
||||||
sysconfig._CONFIG_VARS.update(self._backup_config_vars)
|
sysconfig._CONFIG_VARS.update(self._backup_config_vars)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue