Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
c6fff69d
Commit
c6fff69d
authored
Jul 06, 2020
by
Hai Shi
Committed by
GitHub
Jul 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-40275: Use new test.support helper submodules in tests (GH-21317)
parent
71d869a5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
19 deletions
+19
-19
tests/support.py
tests/support.py
+2
-2
tests/test_build_ext.py
tests/test_build_ext.py
+2
-1
tests/test_filelist.py
tests/test_filelist.py
+6
-7
tests/test_spawn.py
tests/test_spawn.py
+9
-9
No files found.
tests/support.py
View file @
c6fff69d
...
@@ -6,7 +6,7 @@ import tempfile
...
@@ -6,7 +6,7 @@ import tempfile
import
unittest
import
unittest
import
sysconfig
import
sysconfig
from
copy
import
deepcopy
from
copy
import
deepcopy
import
test.support
from
test.support
import
os_helper
from
distutils
import
log
from
distutils
import
log
from
distutils.log
import
DEBUG
,
INFO
,
WARN
,
ERROR
,
FATAL
from
distutils.log
import
DEBUG
,
INFO
,
WARN
,
ERROR
,
FATAL
...
@@ -64,7 +64,7 @@ class TempdirManager(object):
...
@@ -64,7 +64,7 @@ class TempdirManager(object):
super
().
tearDown
()
super
().
tearDown
()
while
self
.
tempdirs
:
while
self
.
tempdirs
:
tmpdir
=
self
.
tempdirs
.
pop
()
tmpdir
=
self
.
tempdirs
.
pop
()
test
.
support
.
rmtree
(
tmpdir
)
os_helper
.
rmtree
(
tmpdir
)
def
mkdtemp
(
self
):
def
mkdtemp
(
self
):
"""Create a temporary directory that will be cleaned up.
"""Create a temporary directory that will be cleaned up.
...
...
tests/test_build_ext.py
View file @
c6fff69d
...
@@ -15,6 +15,7 @@ from distutils.errors import (
...
@@ -15,6 +15,7 @@ from distutils.errors import (
import
unittest
import
unittest
from
test
import
support
from
test
import
support
from
test.support
import
os_helper
from
test.support.script_helper
import
assert_python_ok
from
test.support.script_helper
import
assert_python_ok
# http://bugs.python.org/issue4373
# http://bugs.python.org/issue4373
...
@@ -38,7 +39,7 @@ class BuildExtTestCase(TempdirManager,
...
@@ -38,7 +39,7 @@ class BuildExtTestCase(TempdirManager,
# bpo-30132: On Windows, a .pdb file may be created in the current
# bpo-30132: On Windows, a .pdb file may be created in the current
# working directory. Create a temporary working directory to cleanup
# working directory. Create a temporary working directory to cleanup
# everything at the end of the test.
# 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__
()
change_cwd
.
__enter__
()
self
.
addCleanup
(
change_cwd
.
__exit__
,
None
,
None
,
None
)
self
.
addCleanup
(
change_cwd
.
__exit__
,
None
,
None
,
None
)
...
...
tests/test_filelist.py
View file @
c6fff69d
...
@@ -8,7 +8,6 @@ from distutils.errors import DistutilsTemplateError
...
@@ -8,7 +8,6 @@ from distutils.errors import DistutilsTemplateError
from
distutils.filelist
import
glob_to_re
,
translate_pattern
,
FileList
from
distutils.filelist
import
glob_to_re
,
translate_pattern
,
FileList
from
distutils
import
filelist
from
distutils
import
filelist
import
test.support
from
test.support
import
os_helper
from
test.support
import
os_helper
from
test.support
import
captured_stdout
,
run_unittest
from
test.support
import
captured_stdout
,
run_unittest
from
distutils.tests
import
support
from
distutils.tests
import
support
...
@@ -298,7 +297,7 @@ class FileListTestCase(support.LoggingSilencer,
...
@@ -298,7 +297,7 @@ class FileListTestCase(support.LoggingSilencer,
class
FindAllTestCase
(
unittest
.
TestCase
):
class
FindAllTestCase
(
unittest
.
TestCase
):
@
os_helper
.
skip_unless_symlink
@
os_helper
.
skip_unless_symlink
def
test_missing_symlink
(
self
):
def
test_missing_symlink
(
self
):
with
test
.
support
.
temp_cwd
():
with
os_helper
.
temp_cwd
():
os
.
symlink
(
'foo'
,
'bar'
)
os
.
symlink
(
'foo'
,
'bar'
)
self
.
assertEqual
(
filelist
.
findall
(),
[])
self
.
assertEqual
(
filelist
.
findall
(),
[])
...
@@ -308,13 +307,13 @@ class FindAllTestCase(unittest.TestCase):
...
@@ -308,13 +307,13 @@ class FindAllTestCase(unittest.TestCase):
'.' as the parameter, the dot should be omitted from
'.' as the parameter, the dot should be omitted from
the results.
the results.
"""
"""
with
test
.
support
.
temp_cwd
():
with
os_helper
.
temp_cwd
():
os
.
mkdir
(
'foo'
)
os
.
mkdir
(
'foo'
)
file1
=
os
.
path
.
join
(
'foo'
,
'file1.txt'
)
file1
=
os
.
path
.
join
(
'foo'
,
'file1.txt'
)
test
.
support
.
create_empty_file
(
file1
)
os_helper
.
create_empty_file
(
file1
)
os
.
mkdir
(
'bar'
)
os
.
mkdir
(
'bar'
)
file2
=
os
.
path
.
join
(
'bar'
,
'file2.txt'
)
file2
=
os
.
path
.
join
(
'bar'
,
'file2.txt'
)
test
.
support
.
create_empty_file
(
file2
)
os_helper
.
create_empty_file
(
file2
)
expected
=
[
file2
,
file1
]
expected
=
[
file2
,
file1
]
self
.
assertEqual
(
sorted
(
filelist
.
findall
()),
expected
)
self
.
assertEqual
(
sorted
(
filelist
.
findall
()),
expected
)
...
@@ -323,9 +322,9 @@ class FindAllTestCase(unittest.TestCase):
...
@@ -323,9 +322,9 @@ class FindAllTestCase(unittest.TestCase):
When findall is called with another path, the full
When findall is called with another path, the full
path name should be returned.
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'
)
file1
=
os
.
path
.
join
(
temp_dir
,
'file1.txt'
)
test
.
support
.
create_empty_file
(
file1
)
os_helper
.
create_empty_file
(
file1
)
expected
=
[
file1
]
expected
=
[
file1
]
self
.
assertEqual
(
filelist
.
findall
(
temp_dir
),
expected
)
self
.
assertEqual
(
filelist
.
findall
(
temp_dir
),
expected
)
...
...
tests/test_spawn.py
View file @
c6fff69d
...
@@ -4,7 +4,7 @@ import stat
...
@@ -4,7 +4,7 @@ import stat
import
sys
import
sys
import
unittest.mock
import
unittest.mock
from
test.support
import
run_unittest
,
unix_shell
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
find_executable
from
distutils.spawn
import
spawn
from
distutils.spawn
import
spawn
...
@@ -44,9 +44,9 @@ class SpawnTestCase(support.TempdirManager,
...
@@ -44,9 +44,9 @@ class SpawnTestCase(support.TempdirManager,
spawn
([
exe
])
# should work without any error
spawn
([
exe
])
# should work without any error
def
test_find_executable
(
self
):
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
# 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.
# Give the temporary program an ".exe" suffix for all.
# It's needed on Windows and not harmful on other platforms.
# It's needed on Windows and not harmful on other platforms.
program
=
program_noeext
+
".exe"
program
=
program_noeext
+
".exe"
...
@@ -66,7 +66,7 @@ class SpawnTestCase(support.TempdirManager,
...
@@ -66,7 +66,7 @@ class SpawnTestCase(support.TempdirManager,
self
.
assertEqual
(
rv
,
filename
)
self
.
assertEqual
(
rv
,
filename
)
# test find in the current directory
# test find in the current directory
with
test_support
.
change_cwd
(
tmp_dir
):
with
os_helper
.
change_cwd
(
tmp_dir
):
rv
=
find_executable
(
program
)
rv
=
find_executable
(
program
)
self
.
assertEqual
(
rv
,
program
)
self
.
assertEqual
(
rv
,
program
)
...
@@ -76,7 +76,7 @@ class SpawnTestCase(support.TempdirManager,
...
@@ -76,7 +76,7 @@ class SpawnTestCase(support.TempdirManager,
self
.
assertIsNone
(
rv
)
self
.
assertIsNone
(
rv
)
# PATH='': no match, except in the current directory
# PATH='': no match, except in the current directory
with
test_support
.
EnvironmentVarGuard
()
as
env
:
with
os_helper
.
EnvironmentVarGuard
()
as
env
:
env
[
'PATH'
]
=
''
env
[
'PATH'
]
=
''
with
unittest
.
mock
.
patch
(
'distutils.spawn.os.confstr'
,
with
unittest
.
mock
.
patch
(
'distutils.spawn.os.confstr'
,
return_value
=
tmp_dir
,
create
=
True
),
\
return_value
=
tmp_dir
,
create
=
True
),
\
...
@@ -86,12 +86,12 @@ class SpawnTestCase(support.TempdirManager,
...
@@ -86,12 +86,12 @@ class SpawnTestCase(support.TempdirManager,
self
.
assertIsNone
(
rv
)
self
.
assertIsNone
(
rv
)
# look in current directory
# look in current directory
with
test_support
.
change_cwd
(
tmp_dir
):
with
os_helper
.
change_cwd
(
tmp_dir
):
rv
=
find_executable
(
program
)
rv
=
find_executable
(
program
)
self
.
assertEqual
(
rv
,
program
)
self
.
assertEqual
(
rv
,
program
)
# PATH=':': explicitly looks in the current directory
# PATH=':': explicitly looks in the current directory
with
test_support
.
EnvironmentVarGuard
()
as
env
:
with
os_helper
.
EnvironmentVarGuard
()
as
env
:
env
[
'PATH'
]
=
os
.
pathsep
env
[
'PATH'
]
=
os
.
pathsep
with
unittest
.
mock
.
patch
(
'distutils.spawn.os.confstr'
,
with
unittest
.
mock
.
patch
(
'distutils.spawn.os.confstr'
,
return_value
=
''
,
create
=
True
),
\
return_value
=
''
,
create
=
True
),
\
...
@@ -100,12 +100,12 @@ class SpawnTestCase(support.TempdirManager,
...
@@ -100,12 +100,12 @@ class SpawnTestCase(support.TempdirManager,
self
.
assertIsNone
(
rv
)
self
.
assertIsNone
(
rv
)
# look in current directory
# look in current directory
with
test_support
.
change_cwd
(
tmp_dir
):
with
os_helper
.
change_cwd
(
tmp_dir
):
rv
=
find_executable
(
program
)
rv
=
find_executable
(
program
)
self
.
assertEqual
(
rv
,
program
)
self
.
assertEqual
(
rv
,
program
)
# missing PATH: test os.confstr("CS_PATH") and os.defpath
# 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
)
env
.
pop
(
'PATH'
,
None
)
# without confstr
# without confstr
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment