aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHai Shi <shihai1992@gmail.com>2020-07-06 20:29:49 +0800
committerGitHub <noreply@github.com>2020-07-06 14:29:49 +0200
commitdeb016224cc506503fb05e821a60158c83918ed4 (patch)
tree21b683e93134e016806477e15df1211567441301 /Lib/distutils
parentbpo-37207: Update whatsnews for 3.9 (GH-21337) (diff)
downloadcpython-deb016224cc506503fb05e821a60158c83918ed4.tar.gz
cpython-deb016224cc506503fb05e821a60158c83918ed4.tar.bz2
cpython-deb016224cc506503fb05e821a60158c83918ed4.zip
bpo-40275: Use new test.support helper submodules in tests (GH-21317)
Diffstat (limited to 'Lib/distutils')
-rw-r--r--Lib/distutils/tests/support.py4
-rw-r--r--Lib/distutils/tests/test_build_ext.py3
-rw-r--r--Lib/distutils/tests/test_filelist.py13
-rw-r--r--Lib/distutils/tests/test_spawn.py18
4 files changed, 19 insertions, 19 deletions
diff --git a/Lib/distutils/tests/support.py b/Lib/distutils/tests/support.py
index 259af882ec0..23b907b607e 100644
--- a/Lib/distutils/tests/support.py
+++ b/Lib/distutils/tests/support.py
@@ -6,7 +6,7 @@ import tempfile
import unittest
import sysconfig
from copy import deepcopy
-import test.support
+from test.support import os_helper
from distutils import log
from distutils.log import DEBUG, INFO, WARN, ERROR, FATAL
@@ -64,7 +64,7 @@ class TempdirManager(object):
super().tearDown()
while self.tempdirs:
tmpdir = self.tempdirs.pop()
- test.support.rmtree(tmpdir)
+ os_helper.rmtree(tmpdir)
def mkdtemp(self):
"""Create a temporary directory that will be cleaned up.
diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py
index 5e47e0773a9..f9e0d766d87 100644
--- a/Lib/distutils/tests/test_build_ext.py
+++ b/Lib/distutils/tests/test_build_ext.py
@@ -15,6 +15,7 @@ from distutils.errors import (
import unittest
from test import support
+from test.support import os_helper
from test.support.script_helper import assert_python_ok
# http://bugs.python.org/issue4373
@@ -38,7 +39,7 @@ class BuildExtTestCase(TempdirManager,
# bpo-30132: On Windows, a .pdb file may be created in the current
# working directory. Create a temporary working directory to cleanup
# everything at the end of the test.
- change_cwd = support.change_cwd(self.tmp_dir)
+ change_cwd = os_helper.change_cwd(self.tmp_dir)
change_cwd.__enter__()
self.addCleanup(change_cwd.__exit__, None, None, None)
diff --git a/Lib/distutils/tests/test_filelist.py b/Lib/distutils/tests/test_filelist.py
index 2c26c22617e..cee97d439e6 100644
--- a/Lib/distutils/tests/test_filelist.py
+++ b/Lib/distutils/tests/test_filelist.py
@@ -8,7 +8,6 @@ from distutils.errors import DistutilsTemplateError
from distutils.filelist import glob_to_re, translate_pattern, FileList
from distutils import filelist
-import test.support
from test.support import os_helper
from test.support import captured_stdout, run_unittest
from distutils.tests import support
@@ -298,7 +297,7 @@ class FileListTestCase(support.LoggingSilencer,
class FindAllTestCase(unittest.TestCase):
@os_helper.skip_unless_symlink
def test_missing_symlink(self):
- with test.support.temp_cwd():
+ with os_helper.temp_cwd():
os.symlink('foo', 'bar')
self.assertEqual(filelist.findall(), [])
@@ -308,13 +307,13 @@ class FindAllTestCase(unittest.TestCase):
'.' as the parameter, the dot should be omitted from
the results.
"""
- with test.support.temp_cwd():
+ with os_helper.temp_cwd():
os.mkdir('foo')
file1 = os.path.join('foo', 'file1.txt')
- test.support.create_empty_file(file1)
+ os_helper.create_empty_file(file1)
os.mkdir('bar')
file2 = os.path.join('bar', 'file2.txt')
- test.support.create_empty_file(file2)
+ os_helper.create_empty_file(file2)
expected = [file2, file1]
self.assertEqual(sorted(filelist.findall()), expected)
@@ -323,9 +322,9 @@ class FindAllTestCase(unittest.TestCase):
When findall is called with another path, the full
path name should be returned.
"""
- with test.support.temp_dir() as temp_dir:
+ with os_helper.temp_dir() as temp_dir:
file1 = os.path.join(temp_dir, 'file1.txt')
- test.support.create_empty_file(file1)
+ os_helper.create_empty_file(file1)
expected = [file1]
self.assertEqual(filelist.findall(temp_dir), expected)
diff --git a/Lib/distutils/tests/test_spawn.py b/Lib/distutils/tests/test_spawn.py
index cf1faad5f4d..3647bab7b1c 100644
--- a/Lib/distutils/tests/test_spawn.py
+++ b/Lib/distutils/tests/test_spawn.py
@@ -4,7 +4,7 @@ import stat
import sys
import unittest.mock
from test.support import run_unittest, unix_shell
-from test import support as test_support
+from test.support import os_helper
from distutils.spawn import find_executable
from distutils.spawn import spawn
@@ -44,9 +44,9 @@ class SpawnTestCase(support.TempdirManager,
spawn([exe]) # should work without any error
def test_find_executable(self):
- with test_support.temp_dir() as tmp_dir:
+ with os_helper.temp_dir() as tmp_dir:
# use TESTFN to get a pseudo-unique filename
- program_noeext = test_support.TESTFN
+ program_noeext = os_helper.TESTFN
# Give the temporary program an ".exe" suffix for all.
# It's needed on Windows and not harmful on other platforms.
program = program_noeext + ".exe"
@@ -66,7 +66,7 @@ class SpawnTestCase(support.TempdirManager,
self.assertEqual(rv, filename)
# test find in the current directory
- with test_support.change_cwd(tmp_dir):
+ with os_helper.change_cwd(tmp_dir):
rv = find_executable(program)
self.assertEqual(rv, program)
@@ -76,7 +76,7 @@ class SpawnTestCase(support.TempdirManager,
self.assertIsNone(rv)
# PATH='': no match, except in the current directory
- with test_support.EnvironmentVarGuard() as env:
+ with os_helper.EnvironmentVarGuard() as env:
env['PATH'] = ''
with unittest.mock.patch('distutils.spawn.os.confstr',
return_value=tmp_dir, create=True), \
@@ -86,12 +86,12 @@ class SpawnTestCase(support.TempdirManager,
self.assertIsNone(rv)
# look in current directory
- with test_support.change_cwd(tmp_dir):
+ with os_helper.change_cwd(tmp_dir):
rv = find_executable(program)
self.assertEqual(rv, program)
# PATH=':': explicitly looks in the current directory
- with test_support.EnvironmentVarGuard() as env:
+ with os_helper.EnvironmentVarGuard() as env:
env['PATH'] = os.pathsep
with unittest.mock.patch('distutils.spawn.os.confstr',
return_value='', create=True), \
@@ -100,12 +100,12 @@ class SpawnTestCase(support.TempdirManager,
self.assertIsNone(rv)
# look in current directory
- with test_support.change_cwd(tmp_dir):
+ with os_helper.change_cwd(tmp_dir):
rv = find_executable(program)
self.assertEqual(rv, program)
# missing PATH: test os.confstr("CS_PATH") and os.defpath
- with test_support.EnvironmentVarGuard() as env:
+ with os_helper.EnvironmentVarGuard() as env:
env.pop('PATH', None)
# without confstr