summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-11-29 06:18:11 -0500
committerNed Batchelder <ned@nedbatchelder.com>2016-11-29 06:18:11 -0500
commit998b4e07d8af4d241e70c7cca18a0f72f8ca74dd (patch)
tree6c7feed9b141e3ecc3b274e7a333861b6f66d3c3
parent2ac8b14e315c82f7587382d7d0ef06da7e0eae11 (diff)
downloadpython-coveragepy-998b4e07d8af4d241e70c7cca18a0f72f8ca74dd.tar.gz
More-accurate pragmas
-rw-r--r--coverage/misc.py4
-rw-r--r--metacov.ini1
-rw-r--r--tests/test_oddball.py4
3 files changed, 5 insertions, 4 deletions
diff --git a/coverage/misc.py b/coverage/misc.py
index f376346..9b1894f 100644
--- a/coverage/misc.py
+++ b/coverage/misc.py
@@ -129,12 +129,12 @@ def expensive(fn):
def _wrapped(self):
"""Inner function that checks the cache."""
if hasattr(self, attr):
- raise Exception("Shouldn't have called %s more than once" % fn.__name__)
+ raise AssertionError("Shouldn't have called %s more than once" % fn.__name__)
setattr(self, attr, True)
return fn(self)
return _wrapped
else:
- return fn
+ return fn # pragma: not covered
def bool_or_none(b):
diff --git a/metacov.ini b/metacov.ini
index c59ad81..8170d6d 100644
--- a/metacov.ini
+++ b/metacov.ini
@@ -22,6 +22,7 @@ exclude_lines =
partial_branches =
pragma: part covered
+ pragma: if failure
if env.TESTING:
ignore_errors = true
diff --git a/tests/test_oddball.py b/tests/test_oddball.py
index 7fc122a..e1099e6 100644
--- a/tests/test_oddball.py
+++ b/tests/test_oddball.py
@@ -176,10 +176,10 @@ class MemoryLeakTest(CoverageTest):
# Running the code 10k times shouldn't grow the ram much more than
# running it 10 times.
ram_growth = (ram_10k - ram_10) - (ram_10 - ram_0)
- if ram_growth > 100000: # pragma: only failure
+ if ram_growth > 100000: # pragma: if failure
fails += 1
- if fails > 8: # pragma: only failure
+ if fails > 8: # pragma: if failure
self.fail("RAM grew by %d" % (ram_growth))