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
e7266809
Commit
e7266809
authored
Jun 03, 2016
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract context manager for project_on_sys_path in test command
parent
7dadb206
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
setuptools/command/test.py
setuptools/command/test.py
+16
-5
No files found.
setuptools/command/test.py
View file @
e7266809
import
sys
import
contextlib
from
distutils.errors
import
DistutilsOptionError
from
unittest
import
TestLoader
import
sys
from
setuptools.extern
import
six
from
setuptools.extern.six.moves
import
map
...
...
@@ -102,6 +103,14 @@ class test(Command):
yield
self
.
test_suite
def
with_project_on_sys_path
(
self
,
func
):
"""
Backward compatibility for project_on_sys_path context.
"""
with
self
.
project_on_sys_path
():
func
()
@
contextlib
.
contextmanager
def
project_on_sys_path
(
self
):
with_2to3
=
six
.
PY3
and
getattr
(
self
.
distribution
,
'use_2to3'
,
False
)
if
with_2to3
:
...
...
@@ -137,7 +146,7 @@ class test(Command):
working_set
.
__init__
()
add_activation_listener
(
lambda
dist
:
dist
.
activate
())
require
(
'%s==%s'
%
(
ei_cmd
.
egg_name
,
ei_cmd
.
egg_version
))
func
()
yield
finally
:
sys
.
path
[:]
=
old_path
sys
.
modules
.
clear
()
...
...
@@ -154,9 +163,11 @@ class test(Command):
cmd
=
' '
.
join
(
self
.
_argv
)
if
self
.
dry_run
:
self
.
announce
(
'skipping "%s" (dry run)'
%
cmd
)
else
:
return
self
.
announce
(
'running "%s"'
%
cmd
)
self
.
with_project_on_sys_path
(
self
.
run_tests
)
with
self
.
project_on_sys_path
():
self
.
run_tests
()
def
run_tests
(
self
):
# Purge modules under test from sys.modules. The test loader will
...
...
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