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
61143d61
Commit
61143d61
authored
May 19, 2016
by
Last G
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests for working in environment without site.getsitepakages
parent
6437f524
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
1 deletion
+28
-1
setuptools/tests/test_easy_install.py
setuptools/tests/test_easy_install.py
+28
-1
No files found.
setuptools/tests/test_easy_install.py
View file @
61143d61
...
@@ -41,6 +41,22 @@ from . import contexts
...
@@ -41,6 +41,22 @@ from . import contexts
from
.textwrap
import
DALS
from
.textwrap
import
DALS
@
contextlib
.
contextmanager
def
_mark_removing_patcher
(
obj
,
attr
,
newval
):
setattr
(
obj
,
attr
,
newval
)
try
:
yield
finally
:
delattr
(
obj
,
attr
)
def
magic_patch_object
(
obj
,
attr
,
newval
):
if
hasattr
(
obj
,
attr
):
return
mock
.
patch
.
object
(
obj
,
attr
,
newval
)
else
:
return
_mark_removing_patcher
(
obj
,
attr
,
newval
)
class
FakeDist
(
object
):
class
FakeDist
(
object
):
def
get_entry_map
(
self
,
group
):
def
get_entry_map
(
self
,
group
):
if
group
!=
'console_scripts'
:
if
group
!=
'console_scripts'
:
...
@@ -119,10 +135,21 @@ class TestEasyInstallTest:
...
@@ -119,10 +135,21 @@ class TestEasyInstallTest:
with
pytest
.
raises
(
distutils
.
errors
.
DistutilsError
):
with
pytest
.
raises
(
distutils
.
errors
.
DistutilsError
):
cmd
.
cant_write_to_target
()
cmd
.
cant_write_to_target
()
@
m
ock
.
patch
(
'site.
getsitepackages'
,
lambda
:
[
'/setuptools/test/site-packages'
])
@
m
agic_patch_object
(
site
,
'
getsitepackages'
,
lambda
:
[
'/setuptools/test/site-packages'
])
def
test_all_site_dirs
(
self
):
def
test_all_site_dirs
(
self
):
assert
'/setuptools/test/site-packages'
in
ei
.
get_site_dirs
()
assert
'/setuptools/test/site-packages'
in
ei
.
get_site_dirs
()
def
test_all_site_dirs_works_without_getsitepackages
(
self
):
getsitepackages_old
=
None
if
hasattr
(
site
,
'getsitepackages'
):
getsitepackages_old
=
site
.
getsitepackages
del
site
.
getsitepackages
try
:
assert
ei
.
get_site_dirs
()
finally
:
if
getsitepackages_old
is
not
None
:
site
.
getsitepackages
=
getsitepackages_old
class
TestPTHFileWriter
:
class
TestPTHFileWriter
:
def
test_add_from_cwd_site_sets_dirty
(
self
):
def
test_add_from_cwd_site_sets_dirty
(
self
):
...
...
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