diff options
Diffstat (limited to 'Lib/test/test_tempfile.py')
-rw-r--r-- | Lib/test/test_tempfile.py | 20 |
1 files changed, 12 insertions, 8 deletions
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 @@ from unittest import mock 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 @@ class BaseTestCase(unittest.TestCase): 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 @@ class TestCandidateTempdirList(BaseTestCase): # _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 @@ def _inside_empty_temp_dir(): 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 @@ class TestGetTempDir(BaseTestCase): 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 @@ class TestNamedTemporaryFile(BaseTestCase): 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 @@ class TestTemporaryDirectory(BaseTestCase): 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 @@ class TestTemporaryDirectory(BaseTestCase): 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() |