summaryrefslogtreecommitdiff
path: root/setuptools/tests/test_easy_install.py
diff options
context:
space:
mode:
authorLast G <last_g@hackerdom.ru>2016-05-19 17:31:24 +0200
committerLast G <last_g@hackerdom.ru>2016-05-19 17:31:24 +0200
commit99fb3277660297459fbc080a8c6def98a8c52421 (patch)
treeec594208b7b6e81b90a6c7565f987c71756d1f30 /setuptools/tests/test_easy_install.py
parent61143d61e148ea2d3efa61df1c459c55cdb35739 (diff)
downloadpython-setuptools-git-99fb3277660297459fbc080a8c6def98a8c52421.tar.gz
Replace contextlib with decorator
Diffstat (limited to 'setuptools/tests/test_easy_install.py')
-rw-r--r--setuptools/tests/test_easy_install.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py
index aec65a11..a4fd39fe 100644
--- a/setuptools/tests/test_easy_install.py
+++ b/setuptools/tests/test_easy_install.py
@@ -10,6 +10,7 @@ import shutil
import tempfile
import site
import contextlib
+import functools
import tarfile
import logging
import itertools
@@ -41,20 +42,24 @@ from . import contexts
from .textwrap import DALS
-@contextlib.contextmanager
-def _mark_removing_patcher(obj, attr, newval):
- setattr(obj, attr, newval)
- try:
- yield
- finally:
- delattr(obj, attr)
+def _mock_removing_patcher(obj, attr, newval):
+ def decorator(fn):
+ @functools.wraps(fn)
+ def wrapper(*args, **kwargs):
+ setattr(obj, attr, newval)
+ try:
+ return fn(*args, **kwargs)
+ finally:
+ delattr(obj, attr)
+ return wrapper
+ return decorator
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)
+ return _mock_removing_patcher(obj, attr, newval)
class FakeDist(object):