Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
9b5c7f44
Commit
9b5c7f44
authored
Nov 15, 2011
by
Éric Araujo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused code from packaging.tests.__init__
parent
36500344
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
108 deletions
+10
-108
Lib/packaging/tests/__init__.py
Lib/packaging/tests/__init__.py
+1
-103
Lib/packaging/tests/test_command_bdist.py
Lib/packaging/tests/test_command_bdist.py
+5
-2
Lib/packaging/tests/test_command_sdist.py
Lib/packaging/tests/test_command_sdist.py
+4
-2
Lib/packaging/tests/test_dist.py
Lib/packaging/tests/test_dist.py
+0
-1
No files found.
Lib/packaging/tests/__init__.py
View file @
9b5c7f44
...
...
@@ -14,16 +14,11 @@ standard library for packaging tests and unittest2 for distutils2 tests.
import
os
import
sys
import
unittest
from
io
import
StringIO
# XXX move helpers to support, add tests for them, remove things that
# duplicate test.support (or keep them for the backport; needs thinking)
here
=
os
.
path
.
dirname
(
__file__
)
or
os
.
curdir
verbose
=
1
def
test_suite
():
suite
=
unittest
.
TestSuite
()
here
=
os
.
path
.
dirname
(
__file__
)
or
os
.
curdir
for
fn
in
os
.
listdir
(
here
):
if
fn
.
startswith
(
"test"
)
and
fn
.
endswith
(
".py"
):
modname
=
"packaging.tests."
+
fn
[:
-
3
]
...
...
@@ -31,100 +26,3 @@ def test_suite():
module
=
sys
.
modules
[
modname
]
suite
.
addTest
(
module
.
test_suite
())
return
suite
class
Error
(
Exception
):
"""Base class for regression test exceptions."""
class
TestFailed
(
Error
):
"""Test failed."""
class
BasicTestRunner
:
def
run
(
self
,
test
):
result
=
unittest
.
TestResult
()
test
(
result
)
return
result
def
_run_suite
(
suite
,
verbose_
=
1
):
"""Run tests from a unittest.TestSuite-derived class."""
global
verbose
verbose
=
verbose_
if
verbose_
:
runner
=
unittest
.
TextTestRunner
(
sys
.
stdout
,
verbosity
=
2
)
else
:
runner
=
BasicTestRunner
()
result
=
runner
.
run
(
suite
)
if
not
result
.
wasSuccessful
():
if
len
(
result
.
errors
)
==
1
and
not
result
.
failures
:
err
=
result
.
errors
[
0
][
1
]
elif
len
(
result
.
failures
)
==
1
and
not
result
.
errors
:
err
=
result
.
failures
[
0
][
1
]
else
:
err
=
"errors occurred; run in verbose mode for details"
raise
TestFailed
(
err
)
def
run_unittest
(
classes
,
verbose_
=
1
):
"""Run tests from unittest.TestCase-derived classes.
Originally extracted from stdlib test.test_support and modified to
support unittest2.
"""
valid_types
=
(
unittest
.
TestSuite
,
unittest
.
TestCase
)
suite
=
unittest
.
TestSuite
()
for
cls
in
classes
:
if
isinstance
(
cls
,
str
):
if
cls
in
sys
.
modules
:
suite
.
addTest
(
unittest
.
findTestCases
(
sys
.
modules
[
cls
]))
else
:
raise
ValueError
(
"str arguments must be keys in sys.modules"
)
elif
isinstance
(
cls
,
valid_types
):
suite
.
addTest
(
cls
)
else
:
suite
.
addTest
(
unittest
.
makeSuite
(
cls
))
_run_suite
(
suite
,
verbose_
)
def
reap_children
():
"""Use this function at the end of test_main() whenever sub-processes
are started. This will help ensure that no extra children (zombies)
stick around to hog resources and create problems when looking
for refleaks.
Extracted from stdlib test.support.
"""
# Reap all our dead child processes so we don't leave zombies around.
# These hog resources and might be causing some of the buildbots to die.
if
hasattr
(
os
,
'waitpid'
):
any_process
=
-
1
while
True
:
try
:
# This will raise an exception on Windows. That's ok.
pid
,
status
=
os
.
waitpid
(
any_process
,
os
.
WNOHANG
)
if
pid
==
0
:
break
except
:
break
def
captured_stdout
(
func
,
*
args
,
**
kw
):
orig_stdout
=
getattr
(
sys
,
'stdout'
)
setattr
(
sys
,
'stdout'
,
StringIO
())
try
:
res
=
func
(
*
args
,
**
kw
)
sys
.
stdout
.
seek
(
0
)
return
res
,
sys
.
stdout
.
read
()
finally
:
setattr
(
sys
,
'stdout'
,
orig_stdout
)
def
unload
(
name
):
try
:
del
sys
.
modules
[
name
]
except
KeyError
:
pass
Lib/packaging/tests/test_command_bdist.py
View file @
9b5c7f44
"""Tests for distutils.command.bdist."""
import
os
from
test.support
import
captured_stdout
from
packaging.command.bdist
import
bdist
,
show_formats
from
packaging.tests
import
unittest
,
support
,
captured_stdout
from
packaging.tests
import
unittest
,
support
class
BuildTestCase
(
support
.
TempdirManager
,
...
...
@@ -42,7 +43,9 @@ class BuildTestCase(support.TempdirManager,
'%s should take --skip-build from bdist'
%
name
)
def
test_show_formats
(
self
):
__
,
stdout
=
captured_stdout
(
show_formats
)
with
captured_stdout
()
as
stdout
:
show_formats
()
stdout
=
stdout
.
getvalue
()
# the output should be a header line + one line per format
num_formats
=
len
(
bdist
.
format_commands
)
...
...
Lib/packaging/tests/test_command_sdist.py
View file @
9b5c7f44
...
...
@@ -17,8 +17,8 @@ from packaging.util import find_executable
from
packaging.errors
import
PackagingOptionError
from
packaging.command.sdist
import
sdist
,
show_formats
from
test.support
import
captured_stdout
from
packaging.tests
import
support
,
unittest
from
packaging.tests
import
captured_stdout
from
packaging.tests.support
import
requires_zlib
...
...
@@ -234,7 +234,9 @@ class SDistTestCase(support.TempdirManager,
self
.
assertIn
(
"'setup.cfg' file not found"
,
warnings
[
1
])
def
test_show_formats
(
self
):
__
,
stdout
=
captured_stdout
(
show_formats
)
with
captured_stdout
()
as
stdout
:
show_formats
()
stdout
=
stdout
.
getvalue
()
# the output should be a header line + one line per format
num_formats
=
len
(
get_archive_formats
())
...
...
Lib/packaging/tests/test_dist.py
View file @
9b5c7f44
...
...
@@ -8,7 +8,6 @@ import packaging.dist
from
packaging.dist
import
Distribution
from
packaging.command.cmd
import
Command
from
packaging.errors
import
PackagingModuleError
,
PackagingOptionError
from
packaging.tests
import
captured_stdout
from
packaging.tests
import
support
,
unittest
from
packaging.tests.support
import
create_distribution
,
use_command
from
test.support
import
unload
...
...
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