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
99fb3277
Commit
99fb3277
authored
May 19, 2016
by
Last G
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace contextlib with decorator
parent
61143d61
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
+13
-8
setuptools/tests/test_easy_install.py
setuptools/tests/test_easy_install.py
+13
-8
No files found.
setuptools/tests/test_easy_install.py
View file @
99fb3277
...
@@ -10,6 +10,7 @@ import shutil
...
@@ -10,6 +10,7 @@ import shutil
import
tempfile
import
tempfile
import
site
import
site
import
contextlib
import
contextlib
import
functools
import
tarfile
import
tarfile
import
logging
import
logging
import
itertools
import
itertools
...
@@ -41,20 +42,24 @@ from . import contexts
...
@@ -41,20 +42,24 @@ from . import contexts
from
.textwrap
import
DALS
from
.textwrap
import
DALS
@
contextlib
.
contextmanager
def
_mock_removing_patcher
(
obj
,
attr
,
newval
):
def
_mark_removing_patcher
(
obj
,
attr
,
newval
):
def
decorator
(
fn
):
setattr
(
obj
,
attr
,
newval
)
@
functools
.
wraps
(
fn
)
try
:
def
wrapper
(
*
args
,
**
kwargs
):
yield
setattr
(
obj
,
attr
,
newval
)
finally
:
try
:
delattr
(
obj
,
attr
)
return
fn
(
*
args
,
**
kwargs
)
finally
:
delattr
(
obj
,
attr
)
return
wrapper
return
decorator
def
magic_patch_object
(
obj
,
attr
,
newval
):
def
magic_patch_object
(
obj
,
attr
,
newval
):
if
hasattr
(
obj
,
attr
):
if
hasattr
(
obj
,
attr
):
return
mock
.
patch
.
object
(
obj
,
attr
,
newval
)
return
mock
.
patch
.
object
(
obj
,
attr
,
newval
)
else
:
else
:
return
_m
ar
k_removing_patcher
(
obj
,
attr
,
newval
)
return
_m
oc
k_removing_patcher
(
obj
,
attr
,
newval
)
class
FakeDist
(
object
):
class
FakeDist
(
object
):
...
...
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