bpo-40275: Use new test.support helper submodules in tests (GH-21169)
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
index fcc706e..8ace883 100644
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -15,7 +15,9 @@
import unittest
from test import support
+from test.support import os_helper
from test.support import script_helper
+from test.support import warnings_helper
has_textmode = (tempfile._text_openflags != tempfile._bin_openflags)
@@ -69,7 +71,7 @@
b_check = re.compile(br"^[a-z0-9_-]{8}$")
def setUp(self):
- self._warnings_manager = support.check_warnings()
+ self._warnings_manager = warnings_helper.check_warnings()
self._warnings_manager.__enter__()
warnings.filterwarnings("ignore", category=RuntimeWarning,
message="mktemp", module=__name__)
@@ -224,7 +226,7 @@
# _candidate_tempdir_list contains the expected directories
# Make sure the interesting environment variables are all set.
- with support.EnvironmentVarGuard() as env:
+ with os_helper.EnvironmentVarGuard() as env:
for envname in 'TMPDIR', 'TEMP', 'TMP':
dirname = os.getenv(envname)
if not dirname:
@@ -310,7 +312,7 @@
with support.swap_attr(tempfile, 'tempdir', dir):
yield
finally:
- support.rmtree(dir)
+ os_helper.rmtree(dir)
def _mock_candidate_names(*names):
@@ -594,13 +596,13 @@
case_sensitive_tempdir = tempfile.mkdtemp("-Temp")
_tempdir, tempfile.tempdir = tempfile.tempdir, None
try:
- with support.EnvironmentVarGuard() as env:
+ with os_helper.EnvironmentVarGuard() as env:
# Fake the first env var which is checked as a candidate
env["TMPDIR"] = case_sensitive_tempdir
self.assertEqual(tempfile.gettempdir(), case_sensitive_tempdir)
finally:
tempfile.tempdir = _tempdir
- support.rmdir(case_sensitive_tempdir)
+ os_helper.rmdir(case_sensitive_tempdir)
class TestMkstemp(BaseTestCase):
@@ -950,7 +952,7 @@
def test_bad_mode(self):
dir = tempfile.mkdtemp()
- self.addCleanup(support.rmtree, dir)
+ self.addCleanup(os_helper.rmtree, dir)
with self.assertRaises(ValueError):
tempfile.NamedTemporaryFile(mode='wr', dir=dir)
with self.assertRaises(TypeError):
@@ -1351,7 +1353,7 @@
finally:
os.rmdir(dir)
- @support.skip_unless_symlink
+ @os_helper.skip_unless_symlink
def test_cleanup_with_symlink_to_a_directory(self):
# cleanup() should not follow symlinks to directories (issue #12464)
d1 = self.do_create()
@@ -1448,7 +1450,9 @@
name = d.name
# Check for the resource warning
- with support.check_warnings(('Implicitly', ResourceWarning), quiet=False):
+ with warnings_helper.check_warnings(('Implicitly',
+ ResourceWarning),
+ quiet=False):
warnings.filterwarnings("always", category=ResourceWarning)
del d
support.gc_collect()