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
c243d47e
Commit
c243d47e
authored
Nov 13, 2017
by
Jason R. Coombs
Committed by
GitHub
Nov 13, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1187 from benoit-pierre/fix_test_command
Fix test command
parents
c218b650
db54a708
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
25 deletions
+81
-25
CHANGES.rst
CHANGES.rst
+5
-0
setuptools/command/test.py
setuptools/command/test.py
+11
-0
setuptools/tests/test_test.py
setuptools/tests/test_test.py
+65
-25
No files found.
CHANGES.rst
View file @
c243d47e
v36
.7.2
-------
*
#
701
:
Fixed
duplicate
test
discovery
on
Python
3.
v36
.7.1
v36
.7.1
-------
-------
...
...
setuptools/command/test.py
View file @
c243d47e
...
@@ -18,6 +18,11 @@ from setuptools.py31compat import unittest_main
...
@@ -18,6 +18,11 @@ from setuptools.py31compat import unittest_main
class
ScanningLoader
(
TestLoader
):
class
ScanningLoader
(
TestLoader
):
def
__init__
(
self
):
TestLoader
.
__init__
(
self
)
self
.
_visited
=
set
()
def
loadTestsFromModule
(
self
,
module
,
pattern
=
None
):
def
loadTestsFromModule
(
self
,
module
,
pattern
=
None
):
"""Return a suite of all tests cases contained in the given module
"""Return a suite of all tests cases contained in the given module
...
@@ -25,6 +30,10 @@ class ScanningLoader(TestLoader):
...
@@ -25,6 +30,10 @@ class ScanningLoader(TestLoader):
If the module has an ``additional_tests`` function, call it and add
If the module has an ``additional_tests`` function, call it and add
the return value to the tests.
the return value to the tests.
"""
"""
if
module
in
self
.
_visited
:
return
None
self
.
_visited
.
add
(
module
)
tests
=
[]
tests
=
[]
tests
.
append
(
TestLoader
.
loadTestsFromModule
(
self
,
module
))
tests
.
append
(
TestLoader
.
loadTestsFromModule
(
self
,
module
))
...
@@ -101,6 +110,8 @@ class test(Command):
...
@@ -101,6 +110,8 @@ class test(Command):
return
list
(
self
.
_test_args
())
return
list
(
self
.
_test_args
())
def
_test_args
(
self
):
def
_test_args
(
self
):
if
not
self
.
test_suite
and
sys
.
version_info
>=
(
2
,
7
):
yield
'discover'
if
self
.
verbose
:
if
self
.
verbose
:
yield
'--verbose'
yield
'--verbose'
if
self
.
test_suite
:
if
self
.
test_suite
:
...
...
setuptools/tests/test_test.py
View file @
c243d47e
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
from
distutils
import
log
import
os
import
os
import
site
import
sys
from
distutils.errors
import
DistutilsError
import
pytest
import
pytest
...
@@ -66,26 +66,66 @@ def sample_test(tmpdir_cwd):
...
@@ -66,26 +66,66 @@ def sample_test(tmpdir_cwd):
f
.
write
(
TEST_PY
)
f
.
write
(
TEST_PY
)
@
pytest
.
mark
.
skipif
(
'hasattr(sys, "real_prefix")'
)
@
pytest
.
fixture
@
pytest
.
mark
.
usefixtures
(
'user_override'
)
def
quiet_log
():
@
pytest
.
mark
.
usefixtures
(
'sample_test'
)
# Running some of the other tests will automatically
class
TestTestTest
:
# change the log level to info, messing our output.
def
test_test
(
self
):
log
.
set_verbosity
(
0
)
params
=
dict
(
name
=
'foo'
,
packages
=
[
'name'
,
'name.space'
,
'name.space.tests'
],
@
pytest
.
mark
.
usefixtures
(
'sample_test'
,
'quiet_log'
)
namespace_packages
=
[
'name'
],
def
test_test
(
capfd
):
test_suite
=
'name.space.tests.test_suite'
,
params
=
dict
(
use_2to3
=
True
,
name
=
'foo'
,
)
packages
=
[
'name'
,
'name.space'
,
'name.space.tests'
],
dist
=
Distribution
(
params
)
namespace_packages
=
[
'name'
],
dist
.
script_name
=
'setup.py'
test_suite
=
'name.space.tests.test_suite'
,
cmd
=
test
(
dist
)
use_2to3
=
True
,
cmd
.
user
=
1
)
cmd
.
ensure_finalized
()
dist
=
Distribution
(
params
)
cmd
.
install_dir
=
site
.
USER_SITE
dist
.
script_name
=
'setup.py'
cmd
.
user
=
1
cmd
=
test
(
dist
)
with
contexts
.
quiet
():
cmd
.
ensure_finalized
()
# The test runner calls sys.exit
# The test runner calls sys.exit
with
contexts
.
suppress_exceptions
(
SystemExit
):
with
contexts
.
suppress_exceptions
(
SystemExit
):
cmd
.
run
()
cmd
.
run
()
out
,
err
=
capfd
.
readouterr
()
assert
out
==
'Foo
\
n
'
@
pytest
.
mark
.
xfail
(
sys
.
version_info
<
(
2
,
7
),
reason
=
"No discover support for unittest on Python 2.6"
,
)
@
pytest
.
mark
.
usefixtures
(
'tmpdir_cwd'
,
'quiet_log'
)
def
test_tests_are_run_once
(
capfd
):
params
=
dict
(
name
=
'foo'
,
packages
=
[
'dummy'
],
)
with
open
(
'setup.py'
,
'wt'
)
as
f
:
f
.
write
(
'from setuptools import setup; setup(
\
n
'
)
for
k
,
v
in
sorted
(
params
.
items
()):
f
.
write
(
' %s=%r,
\
n
'
%
(
k
,
v
))
f
.
write
(
')
\
n
'
)
os
.
makedirs
(
'dummy'
)
with
open
(
'dummy/__init__.py'
,
'wt'
):
pass
with
open
(
'dummy/test_dummy.py'
,
'wt'
)
as
f
:
f
.
write
(
DALS
(
"""
from __future__ import print_function
import unittest
class TestTest(unittest.TestCase):
def test_test(self):
print('Foo')
"""
))
dist
=
Distribution
(
params
)
dist
.
script_name
=
'setup.py'
cmd
=
test
(
dist
)
cmd
.
ensure_finalized
()
# The test runner calls sys.exit
with
contexts
.
suppress_exceptions
(
SystemExit
):
cmd
.
run
()
out
,
err
=
capfd
.
readouterr
()
assert
out
==
'Foo
\
n
'
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