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
bc7f3b0a
Commit
bc7f3b0a
authored
Nov 24, 2015
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract setup/teardown methods as proper fixtures.
parent
3bcf6213
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
27 deletions
+30
-27
setuptools/tests/test_develop.py
setuptools/tests/test_develop.py
+30
-27
No files found.
setuptools/tests/test_develop.py
View file @
bc7f3b0a
...
...
@@ -6,8 +6,12 @@ import site
import
sys
import
tempfile
import
pytest
from
setuptools.command.develop
import
develop
from
setuptools.dist
import
Distribution
from
.
import
contexts
SETUP_PY
=
"""
\
from setuptools import setup
...
...
@@ -21,43 +25,42 @@ setup(name='foo',
INIT_PY
=
"""print "foo"
"""
@
pytest
.
yield_fixture
def
temp_user
(
monkeypatch
):
with
contexts
.
tempdir
()
as
user_base
:
with
contexts
.
tempdir
()
as
user_site
:
monkeypatch
.
setattr
(
'site.USER_BASE'
,
user_base
)
monkeypatch
.
setattr
(
'site.USER_SITE'
,
user_site
)
yield
@
pytest
.
yield_fixture
def
test_env
(
tmpdir
,
temp_user
):
target
=
tmpdir
foo
=
target
.
mkdir
(
'foo'
)
setup
=
target
/
'setup.py'
if
setup
.
isfile
():
raise
ValueError
(
dir
(
target
))
with
setup
.
open
(
'w'
)
as
f
:
f
.
write
(
SETUP_PY
)
init
=
foo
/
'__init__.py'
with
init
.
open
(
'w'
)
as
f
:
f
.
write
(
INIT_PY
)
with
target
.
as_cwd
():
yield
target
class
TestDevelopTest
:
def
setup_method
(
self
,
method
):
if
hasattr
(
sys
,
'real_prefix'
):
return
# Directory structure
self
.
dir
=
tempfile
.
mkdtemp
()
os
.
mkdir
(
os
.
path
.
join
(
self
.
dir
,
'foo'
))
# setup.py
setup
=
os
.
path
.
join
(
self
.
dir
,
'setup.py'
)
with
open
(
setup
,
'w'
)
as
f
:
f
.
write
(
SETUP_PY
)
self
.
old_cwd
=
os
.
getcwd
()
# foo/__init__.py
init
=
os
.
path
.
join
(
self
.
dir
,
'foo'
,
'__init__.py'
)
with
open
(
init
,
'w'
)
as
f
:
f
.
write
(
INIT_PY
)
os
.
chdir
(
self
.
dir
)
self
.
old_base
=
site
.
USER_BASE
site
.
USER_BASE
=
tempfile
.
mkdtemp
()
self
.
old_site
=
site
.
USER_SITE
site
.
USER_SITE
=
tempfile
.
mkdtemp
()
def
teardown_method
(
self
,
method
):
if
hasattr
(
sys
,
'real_prefix'
)
or
(
hasattr
(
sys
,
'base_prefix'
)
and
sys
.
base_prefix
!=
sys
.
prefix
):
return
os
.
chdir
(
self
.
old_cwd
)
shutil
.
rmtree
(
self
.
dir
)
shutil
.
rmtree
(
site
.
USER_BASE
)
shutil
.
rmtree
(
site
.
USER_SITE
)
site
.
USER_BASE
=
self
.
old_base
site
.
USER_SITE
=
self
.
old_site
def
test_develop
(
self
):
def
test_develop
(
self
,
test_env
):
if
hasattr
(
sys
,
'real_prefix'
):
return
dist
=
Distribution
(
...
...
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