summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tools
diff options
context:
space:
mode:
authorHai Shi <shihai1992@gmail.com>2020-08-04 15:53:12 (GMT)
committerGitHub <noreply@github.com>2020-08-04 15:53:12 (GMT)
commitc7decc27d529c04a4e6b2922e3f3f9419b920f63 (patch)
tree9bcb971af68ed2e08f4aa4001412d38520194cff /Lib/test/test_tools
parent604bba1f8fe32479c89b9824b2231cc4480dd110 (diff)
downloadcpython-c7decc27d529c04a4e6b2922e3f3f9419b920f63.zip
cpython-c7decc27d529c04a4e6b2922e3f3f9419b920f63.tar.gz
cpython-c7decc27d529c04a4e6b2922e3f3f9419b920f63.tar.bz2
bpo-40275: Use new test.support helper submodules in tests (GH-21727)
Diffstat (limited to 'Lib/test/test_tools')
-rw-r--r--Lib/test/test_tools/test_fixcid.py15
-rw-r--r--Lib/test/test_tools/test_i18n.py2
-rw-r--r--Lib/test/test_tools/test_lll.py3
-rw-r--r--Lib/test/test_tools/test_pathfix.py9
-rw-r--r--Lib/test/test_tools/test_pindent.py3
-rw-r--r--Lib/test/test_tools/test_sundry.py6
6 files changed, 21 insertions, 17 deletions
diff --git a/Lib/test/test_tools/test_fixcid.py b/Lib/test/test_tools/test_fixcid.py
index bce029b..3df1368 100644
--- a/Lib/test/test_tools/test_fixcid.py
+++ b/Lib/test/test_tools/test_fixcid.py
@@ -5,6 +5,7 @@ import os, os.path
import runpy
import sys
from test import support
+from test.support import os_helper
from test.test_tools import skip_if_missing, scriptsdir
import unittest
@@ -57,15 +58,15 @@ class Test(unittest.TestCase):
)
def test_directory(self):
- os.mkdir(support.TESTFN)
- self.addCleanup(support.rmtree, support.TESTFN)
- c_filename = os.path.join(support.TESTFN, "file.c")
+ os.mkdir(os_helper.TESTFN)
+ self.addCleanup(os_helper.rmtree, os_helper.TESTFN)
+ c_filename = os.path.join(os_helper.TESTFN, "file.c")
with open(c_filename, "w") as file:
file.write("int xx;\n")
- with open(os.path.join(support.TESTFN, "file.py"), "w") as file:
+ with open(os.path.join(os_helper.TESTFN, "file.py"), "w") as file:
file.write("xx = 'unaltered'\n")
script = os.path.join(scriptsdir, "fixcid.py")
- output = self.run_script(args=(support.TESTFN,))
+ output = self.run_script(args=(os_helper.TESTFN,))
self.assertMultiLineEqual(output,
"{}:\n"
"1\n"
@@ -74,10 +75,10 @@ class Test(unittest.TestCase):
)
def run_script(self, input="", *, args=("-",), substfile="xx yy\n"):
- substfilename = support.TESTFN + ".subst"
+ substfilename = os_helper.TESTFN + ".subst"
with open(substfilename, "w") as file:
file.write(substfile)
- self.addCleanup(support.unlink, substfilename)
+ self.addCleanup(os_helper.unlink, substfilename)
argv = ["fixcid.py", "-s", substfilename] + list(args)
script = os.path.join(scriptsdir, "fixcid.py")
diff --git a/Lib/test/test_tools/test_i18n.py b/Lib/test/test_tools/test_i18n.py
index 42e20f8..8da6579 100644
--- a/Lib/test/test_tools/test_i18n.py
+++ b/Lib/test/test_tools/test_i18n.py
@@ -7,7 +7,7 @@ from textwrap import dedent
from test.support.script_helper import assert_python_ok
from test.test_tools import skip_if_missing, toolsdir
-from test.support import temp_cwd, temp_dir
+from test.support.os_helper import temp_cwd, temp_dir
skip_if_missing()
diff --git a/Lib/test/test_tools/test_lll.py b/Lib/test/test_tools/test_lll.py
index 568cbfb..ec0c973 100644
--- a/Lib/test/test_tools/test_lll.py
+++ b/Lib/test/test_tools/test_lll.py
@@ -3,6 +3,7 @@
import os
import tempfile
from test import support
+from test.support import os_helper
from test.test_tools import skip_if_missing, import_tool
import unittest
@@ -14,7 +15,7 @@ class lllTests(unittest.TestCase):
def setUp(self):
self.lll = import_tool('lll')
- @support.skip_unless_symlink
+ @os_helper.skip_unless_symlink
def test_lll_multiple_dirs(self):
with tempfile.TemporaryDirectory() as dir1, \
tempfile.TemporaryDirectory() as dir2:
diff --git a/Lib/test/test_tools/test_pathfix.py b/Lib/test/test_tools/test_pathfix.py
index 03ed29d..ff61935 100644
--- a/Lib/test/test_tools/test_pathfix.py
+++ b/Lib/test/test_tools/test_pathfix.py
@@ -3,6 +3,7 @@ import subprocess
import sys
import unittest
from test import support
+from test.support import os_helper
from test.test_tools import scriptsdir, skip_if_missing
@@ -14,7 +15,7 @@ class TestPathfixFunctional(unittest.TestCase):
script = os.path.join(scriptsdir, 'pathfix.py')
def setUp(self):
- self.addCleanup(support.unlink, support.TESTFN)
+ self.addCleanup(os_helper.unlink, os_helper.TESTFN)
def pathfix(self, shebang, pathfix_flags, exitcode=0, stdout='', stderr='',
directory=''):
@@ -24,7 +25,7 @@ class TestPathfixFunctional(unittest.TestCase):
filename = os.path.join(directory, 'script-A_1.py')
pathfix_arg = directory
else:
- filename = support.TESTFN
+ filename = os_helper.TESTFN
pathfix_arg = filename
with open(filename, 'w', encoding='utf8') as f:
@@ -56,8 +57,8 @@ class TestPathfixFunctional(unittest.TestCase):
return new_shebang
def test_recursive(self):
- tmpdir = support.TESTFN + '.d'
- self.addCleanup(support.rmtree, tmpdir)
+ tmpdir = os_helper.TESTFN + '.d'
+ self.addCleanup(os_helper.rmtree, tmpdir)
os.mkdir(tmpdir)
expected_stderr = f"recursedown('{os.path.basename(tmpdir)}')\n"
self.assertEqual(
diff --git a/Lib/test/test_tools/test_pindent.py b/Lib/test/test_tools/test_pindent.py
index e293bc8..e7a547a 100644
--- a/Lib/test/test_tools/test_pindent.py
+++ b/Lib/test/test_tools/test_pindent.py
@@ -6,6 +6,7 @@ import unittest
import subprocess
import textwrap
from test import support
+from test.support import os_helper
from test.support.script_helper import assert_python_ok
from test.test_tools import scriptsdir, skip_if_missing
@@ -34,7 +35,7 @@ class PindentTests(unittest.TestCase):
def test_selftest(self):
self.maxDiff = None
- with support.temp_dir() as directory:
+ with os_helper.temp_dir() as directory:
data_path = os.path.join(directory, '_test.py')
with open(self.script) as f:
closed = f.read()
diff --git a/Lib/test/test_tools/test_sundry.py b/Lib/test/test_tools/test_sundry.py
index 10eb694..8b5a963 100644
--- a/Lib/test/test_tools/test_sundry.py
+++ b/Lib/test/test_tools/test_sundry.py
@@ -8,7 +8,7 @@ tests of their own.
import os
import sys
import unittest
-from test import support
+from test.support import import_helper
from test.test_tools import scriptsdir, import_tool, skip_if_missing
@@ -30,7 +30,7 @@ class TestSundryScripts(unittest.TestCase):
skiplist = blacklist + whitelist + windows_only + other
def test_sundry(self):
- old_modules = support.modules_setup()
+ old_modules = import_helper.modules_setup()
try:
for fn in os.listdir(scriptsdir):
if not fn.endswith('.py'):
@@ -43,7 +43,7 @@ class TestSundryScripts(unittest.TestCase):
import_tool(name)
finally:
# Unload all modules loaded in this test
- support.modules_cleanup(*old_modules)
+ import_helper.modules_cleanup(*old_modules)
@unittest.skipIf(sys.platform != "win32", "Windows-only test")
def test_sundry_windows(self):