diff options
-rw-r--r-- | coverage/debug.py | 8 | ||||
-rw-r--r-- | coverage/misc.py | 9 | ||||
-rw-r--r-- | pylintrc | 4 | ||||
-rw-r--r-- | tests/coveragetest.py | 5 |
4 files changed, 12 insertions, 14 deletions
diff --git a/coverage/debug.py b/coverage/debug.py index cf90f77a..9077a3af 100644 --- a/coverage/debug.py +++ b/coverage/debug.py @@ -303,12 +303,12 @@ def decorate_methods(decorator, butnot=()): # pragma: debugging def break_in_pudb(func): # pragma: debugging """A function decorator to stop in the debugger for each call.""" @functools.wraps(func) - def wrapper(*args, **kwargs): + def _wrapper(*args, **kwargs): import pudb # pylint: disable=import-error sys.stdout = sys.__stdout__ pudb.set_trace() return func(*args, **kwargs) - return wrapper + return _wrapper OBJ_IDS = itertools.count() @@ -319,7 +319,7 @@ def show_calls(show_args=True, show_stack=False): # pragma: debugging """A method decorator to debug-log each call to the function.""" def _decorator(func): @functools.wraps(func) - def wrapper(self, *args, **kwargs): + def _wrapper(self, *args, **kwargs): oid = getattr(self, OBJ_ID_ATTR, None) if oid is None: oid = "{:08d} {:04d}".format(os.getpid(), next(OBJ_IDS)) @@ -340,7 +340,7 @@ def show_calls(show_args=True, show_stack=False): # pragma: debugging msg = "{} {:04d} {}{}\n".format(oid, next(CALLS), func.__name__, extra) DebugOutputFile.get_one().write(msg) return func(self, *args, **kwargs) - return wrapper + return _wrapper return _decorator diff --git a/coverage/misc.py b/coverage/misc.py index 7b8fbb93..a923829d 100644 --- a/coverage/misc.py +++ b/coverage/misc.py @@ -70,11 +70,11 @@ if env.TESTING: """Ensure that only one of the argnames is non-None.""" def _decorator(func): argnameset = set(name.strip() for name in argnames.split(",")) - def _wrapped(*args, **kwargs): + def _wrapper(*args, **kwargs): vals = [kwargs.get(name) for name in argnameset] assert sum(val is not None for val in vals) == 1 return func(*args, **kwargs) - return _wrapped + return _wrapper return _decorator else: # pragma: not testing # We aren't using real PyContracts, so just define our decorators as @@ -149,13 +149,12 @@ def expensive(fn): if env.TESTING: attr = "_once_" + fn.__name__ - def _wrapped(self): - """Inner function that checks the cache.""" + def _wrapper(self): if hasattr(self, attr): raise AssertionError("Shouldn't have called %s more than once" % fn.__name__) setattr(self, attr, True) return fn(self) - return _wrapped + return _wrapper else: return fn # pragma: not testing @@ -133,9 +133,9 @@ evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / stateme # Special methods don't: __foo__ # Test methods don't: testXXXX # TestCase overrides don't: setUp, tearDown -# Nested decorator implementations: _decorator, _wrapped +# Nested decorator implementations: _decorator, _wrapper # Dispatched methods don't: _xxx__Xxxx -no-docstring-rgx=__.*__|test[A-Z_].*|setUp|tearDown|_decorator|_wrapped|_.*__.* +no-docstring-rgx=__.*__|test[A-Z_].*|setUp|tearDown|_decorator|_wrapper|_.*__.* # Regular expression which should only match correct module names module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ diff --git a/tests/coveragetest.py b/tests/coveragetest.py index 15c61ece..378097c8 100644 --- a/tests/coveragetest.py +++ b/tests/coveragetest.py @@ -40,14 +40,13 @@ TESTS_DIR = os.path.dirname(__file__) def convert_skip_exceptions(method): """A decorator for test methods to convert StopEverything to SkipTest.""" @functools.wraps(method) - def wrapper(*args, **kwargs): - """Run the test method, and convert exceptions.""" + def _wrapper(*args, **kwargs): try: result = method(*args, **kwargs) except StopEverything: raise unittest.SkipTest("StopEverything!") return result - return wrapper + return _wrapper class SkipConvertingMetaclass(type): |