Skip to content

Commit 42c0c58

Browse files
committed
Name decorator components to avoid docstring requirement
1 parent c6b688a commit 42c0c58

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

coverage/debug.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,12 @@ def _decorator(cls):
303303
def break_in_pudb(func): # pragma: debugging
304304
"""A function decorator to stop in the debugger for each call."""
305305
@functools.wraps(func)
306-
def wrapper(*args, **kwargs):
306+
def _wrapper(*args, **kwargs):
307307
import pudb # pylint: disable=import-error
308308
sys.stdout = sys.__stdout__
309309
pudb.set_trace()
310310
return func(*args, **kwargs)
311-
return wrapper
311+
return _wrapper
312312

313313

314314
OBJ_IDS = itertools.count()
@@ -319,7 +319,7 @@ def show_calls(show_args=True, show_stack=False): # pragma: debugging
319319
"""A method decorator to debug-log each call to the function."""
320320
def _decorator(func):
321321
@functools.wraps(func)
322-
def wrapper(self, *args, **kwargs):
322+
def _wrapper(self, *args, **kwargs):
323323
oid = getattr(self, OBJ_ID_ATTR, None)
324324
if oid is None:
325325
oid = "{:08d} {:04d}".format(os.getpid(), next(OBJ_IDS))
@@ -340,7 +340,7 @@ def wrapper(self, *args, **kwargs):
340340
msg = "{} {:04d} {}{}\n".format(oid, next(CALLS), func.__name__, extra)
341341
DebugOutputFile.get_one().write(msg)
342342
return func(self, *args, **kwargs)
343-
return wrapper
343+
return _wrapper
344344
return _decorator
345345

346346

coverage/misc.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ def one_of(argnames):
7070
"""Ensure that only one of the argnames is non-None."""
7171
def _decorator(func):
7272
argnameset = set(name.strip() for name in argnames.split(","))
73-
def _wrapped(*args, **kwargs):
73+
def _wrapper(*args, **kwargs):
7474
vals = [kwargs.get(name) for name in argnameset]
7575
assert sum(val is not None for val in vals) == 1
7676
return func(*args, **kwargs)
77-
return _wrapped
77+
return _wrapper
7878
return _decorator
7979
else: # pragma: not testing
8080
# We aren't using real PyContracts, so just define our decorators as
@@ -149,13 +149,12 @@ def expensive(fn):
149149
if env.TESTING:
150150
attr = "_once_" + fn.__name__
151151

152-
def _wrapped(self):
153-
"""Inner function that checks the cache."""
152+
def _wrapper(self):
154153
if hasattr(self, attr):
155154
raise AssertionError("Shouldn't have called %s more than once" % fn.__name__)
156155
setattr(self, attr, True)
157156
return fn(self)
158-
return _wrapped
157+
return _wrapper
159158
else:
160159
return fn # pragma: not testing
161160

pylintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / stateme
133133
# Special methods don't: __foo__
134134
# Test methods don't: testXXXX
135135
# TestCase overrides don't: setUp, tearDown
136-
# Nested decorator implementations: _decorator, _wrapped
136+
# Nested decorator implementations: _decorator, _wrapper
137137
# Dispatched methods don't: _xxx__Xxxx
138-
no-docstring-rgx=__.*__|test[A-Z_].*|setUp|tearDown|_decorator|_wrapped|_.*__.*
138+
no-docstring-rgx=__.*__|test[A-Z_].*|setUp|tearDown|_decorator|_wrapper|_.*__.*
139139

140140
# Regular expression which should only match correct module names
141141
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$

tests/coveragetest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,13 @@
4040
def convert_skip_exceptions(method):
4141
"""A decorator for test methods to convert StopEverything to SkipTest."""
4242
@functools.wraps(method)
43-
def wrapper(*args, **kwargs):
44-
"""Run the test method, and convert exceptions."""
43+
def _wrapper(*args, **kwargs):
4544
try:
4645
result = method(*args, **kwargs)
4746
except StopEverything:
4847
raise unittest.SkipTest("StopEverything!")
4948
return result
50-
return wrapper
49+
return _wrapper
5150

5251

5352
class SkipConvertingMetaclass(type):

0 commit comments

Comments
 (0)