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
9179bdd0
Commit
9179bdd0
authored
Jun 03, 2014
by
Matthew Iversen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup fixture using tmp and monkeypatch
parent
d9fd333e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
28 deletions
+20
-28
setuptools/tests/test_integration.py
setuptools/tests/test_integration.py
+20
-28
No files found.
setuptools/tests/test_integration.py
View file @
9179bdd0
...
@@ -5,10 +5,7 @@ Try to install a few packages.
...
@@ -5,10 +5,7 @@ Try to install a few packages.
import
glob
import
glob
import
os
import
os
import
shutil
import
site
import
sys
import
sys
import
tempfile
import
pytest
import
pytest
...
@@ -18,44 +15,35 @@ from setuptools.dist import Distribution
...
@@ -18,44 +15,35 @@ from setuptools.dist import Distribution
@
pytest
.
fixture
@
pytest
.
fixture
def
install_context
(
request
):
def
install_context
(
request
,
tmpdir
,
monkeypatch
):
"""Fixture to set up temporary installation directory.
"""Fixture to set up temporary installation directory.
"""
"""
# Save old values so we can restore them.
# Save old values so we can restore them.
new_cwd
=
tempfile
.
mkdtemp
()
new_cwd
=
tmpdir
.
mkdir
(
'cwd'
)
old_cwd
=
os
.
getcwd
()
user_base
=
tmpdir
.
mkdir
(
'user_base'
)
old_enable_site
=
site
.
ENABLE_USER_SITE
user_site
=
tmpdir
.
mkdir
(
'user_site'
)
old_file
=
easy_install_pkg
.
__file__
install_dir
=
tmpdir
.
mkdir
(
'install_dir'
)
old_base
=
site
.
USER_BASE
old_site
=
site
.
USER_SITE
old_ppath
=
os
.
environ
.
get
(
'PYTHONPATH'
)
def
fin
():
def
fin
():
os
.
chdir
(
old_cwd
)
new_cwd
.
remove
()
shutil
.
rmtree
(
new_cwd
)
user_base
.
remove
()
shutil
.
rmtree
(
site
.
USER_BASE
)
user_site
.
remove
()
shutil
.
rmtree
(
site
.
USER_SITE
)
install_dir
.
remove
()
site
.
USER_BASE
=
old_base
site
.
USER_SITE
=
old_site
site
.
ENABLE_USER_SITE
=
old_enable_site
easy_install_pkg
.
__file__
=
old_file
os
.
environ
[
'PYTHONPATH'
]
=
old_ppath
or
''
request
.
addfinalizer
(
fin
)
request
.
addfinalizer
(
fin
)
# Change the environment and site settings to control where the
# Change the environment and site settings to control where the
# files are installed and ensure we do not overwrite anything.
# files are installed and ensure we do not overwrite anything.
site
.
USER_BASE
=
tempfile
.
mkdtemp
()
monkeypatch
.
chdir
(
new_cwd
)
site
.
USER_SITE
=
tempfile
.
mkdtemp
()
monkeypatch
.
setattr
(
easy_install_pkg
,
'__file__'
,
user_site
.
strpath
)
easy_install_pkg
.
__file__
=
site
.
USER_SITE
monkeypatch
.
setattr
(
'site.USER_BASE'
,
user_base
.
strpath
)
os
.
chdir
(
new_cwd
)
monkeypatch
.
setattr
(
'site.USER_SITE'
,
user_site
.
strpath
)
install_dir
=
tempfile
.
mkdtemp
()
monkeypatch
.
setattr
(
'sys.path'
,
sys
.
path
+
[
install_dir
.
strpath
])
sys
.
path
.
append
(
install_dir
)
monkeypatch
.
setenv
(
'PYTHONPATH'
,
os
.
path
.
pathsep
.
join
(
sys
.
path
))
os
.
environ
[
'PYTHONPATH'
]
=
os
.
path
.
pathsep
.
join
(
sys
.
path
)
# Set up the command for performing the installation.
# Set up the command for performing the installation.
dist
=
Distribution
()
dist
=
Distribution
()
cmd
=
easy_install
(
dist
)
cmd
=
easy_install
(
dist
)
cmd
.
install_dir
=
install_dir
cmd
.
install_dir
=
install_dir
.
strpath
return
cmd
return
cmd
...
@@ -68,20 +56,24 @@ def _install_one(requirement, cmd, pkgname, modulename):
...
@@ -68,20 +56,24 @@ def _install_one(requirement, cmd, pkgname, modulename):
assert
dest_path
assert
dest_path
assert
os
.
path
.
exists
(
os
.
path
.
join
(
dest_path
[
0
],
pkgname
,
modulename
))
assert
os
.
path
.
exists
(
os
.
path
.
join
(
dest_path
[
0
],
pkgname
,
modulename
))
def
test_stevedore
(
install_context
):
def
test_stevedore
(
install_context
):
_install_one
(
'stevedore'
,
install_context
,
_install_one
(
'stevedore'
,
install_context
,
'stevedore'
,
'extension.py'
)
'stevedore'
,
'extension.py'
)
@
pytest
.
mark
.
xfail
@
pytest
.
mark
.
xfail
def
test_virtualenvwrapper
(
install_context
):
def
test_virtualenvwrapper
(
install_context
):
_install_one
(
'virtualenvwrapper'
,
install_context
,
_install_one
(
'virtualenvwrapper'
,
install_context
,
'virtualenvwrapper'
,
'hook_loader.py'
)
'virtualenvwrapper'
,
'hook_loader.py'
)
@
pytest
.
mark
.
xfail
@
pytest
.
mark
.
xfail
def
test_pbr
(
install_context
):
def
test_pbr
(
install_context
):
_install_one
(
'pbr'
,
install_context
,
_install_one
(
'pbr'
,
install_context
,
'pbr'
,
'core.py'
)
'pbr'
,
'core.py'
)
@
pytest
.
mark
.
xfail
@
pytest
.
mark
.
xfail
def
test_python_novaclient
(
install_context
):
def
test_python_novaclient
(
install_context
):
_install_one
(
'python-novaclient'
,
install_context
,
_install_one
(
'python-novaclient'
,
install_context
,
...
...
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