summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/test_farm.py35
-rw-r--r--tests/test_oddball.py12
2 files changed, 17 insertions, 30 deletions
diff --git a/tests/test_farm.py b/tests/test_farm.py
index 7c9ac012..0155abd8 100644
--- a/tests/test_farm.py
+++ b/tests/test_farm.py
@@ -85,7 +85,7 @@ class FarmTestCase(ModuleAwareMixin, SysPathAwareMixin, unittest.TestCase):
"""Test tear down, run by the test runner after __call__."""
# Make sure the test is cleaned up, unless we never want to, or if the
# test failed.
- if not self.dont_clean and self.ok: # pragma: part covered
+ if not self.dont_clean and self.ok: # pragma: part covered
self.clean_only = True
self()
@@ -95,19 +95,19 @@ class FarmTestCase(ModuleAwareMixin, SysPathAwareMixin, unittest.TestCase):
# don't do cleanups in that case. Do them now.
self.doCleanups()
- def runTest(self):
+ def runTest(self): # pragma: not covered
"""Here to make unittest.TestCase happy, but will never be invoked."""
raise Exception("runTest isn't used in this class!")
def __call__(self):
"""Execute the test from the run.py file."""
- if _TEST_NAME_FILE: # pragma: debugging
+ if _TEST_NAME_FILE: # pragma: debugging
with open(_TEST_NAME_FILE, "w") as f:
f.write(self.description.replace("/", "_"))
# Prepare a dictionary of globals for the run.py files to use.
fns = """
- copy run runfunc clean skip
+ copy run clean skip
compare contains contains_any doesnt_contain
""".split()
if self.clean_only:
@@ -169,26 +169,12 @@ def run(cmds, rundir="src", outfile=None):
if outfile:
fout.write(output)
if retcode:
- raise Exception("command exited abnormally")
+ raise Exception("command exited abnormally") # pragma: only failure
finally:
if outfile:
fout.close()
-def runfunc(fn, rundir="src", addtopath=None):
- """Run a function.
-
- `fn` is a callable.
- `rundir` is the directory in which to run the function.
-
- """
- with change_dir(rundir):
- with saved_sys_path():
- if addtopath is not None:
- sys.path.insert(0, addtopath)
- fn()
-
-
def compare(
dir1, dir2, file_pattern=None, size_within=0,
left_extra=False, right_extra=False, scrubs=None
@@ -249,9 +235,9 @@ def compare(
if (big - little) / float(little) > size_within/100.0:
# print "%d %d" % (big, little)
# print "Left: ---\n%s\n-----\n%s" % (left, right)
- wrong_size.append("%s (%s,%s)" % (f, size_l, size_r))
+ wrong_size.append("%s (%s,%s)" % (f, size_l, size_r)) # pragma: only failure
if wrong_size:
- print("File sizes differ between %s and %s: %s" % (
+ print("File sizes differ between %s and %s: %s" % ( # pragma: only failure
dir1, dir2, ", ".join(wrong_size)
))
@@ -271,7 +257,7 @@ def compare(
if scrubs:
left = scrub(left, scrubs)
right = scrub(right, scrubs)
- if left != right:
+ if left != right: # pragma: only failure
text_diff.append(f)
left = left.splitlines()
right = right.splitlines()
@@ -309,7 +295,8 @@ def contains_any(filename, *strlist):
for s in strlist:
if s in text:
return
- assert False, "Missing content in %s: %r [1 of %d]" % (filename, strlist[0], len(strlist),)
+ else: # pragma: only failure
+ assert False, "Missing content in %s: %r [1 of %d]" % (filename, strlist[0], len(strlist),)
def doesnt_contain(filename, *strlist):
@@ -407,5 +394,5 @@ def main(): # pragma: not covered
print(main.__doc__)
# So that we can run just one farm run.py at a time.
-if __name__ == '__main__':
+if __name__ == '__main__': # pragma: not covered
main()
diff --git a/tests/test_oddball.py b/tests/test_oddball.py
index d188aa78..da6c8fbb 100644
--- a/tests/test_oddball.py
+++ b/tests/test_oddball.py
@@ -179,17 +179,17 @@ 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: if failure
- fails += 1
+ if ram_growth > 100000:
+ fails += 1 # pragma: only failure
- if fails > 8: # pragma: if failure
- self.fail("RAM grew by %d" % (ram_growth))
+ if fails > 8:
+ self.fail("RAM grew by %d" % (ram_growth)) # pragma: only failure
class MemoryFumblingTest(CoverageTest):
"""Test that we properly manage the None refcount."""
- def test_dropping_none(self):
+ def test_dropping_none(self): # pragma: not covered
if not env.C_TRACER:
self.skipTest("Only the C tracer has refcounting issues")
# TODO: Mark this so it will only be run sometimes.
@@ -491,7 +491,7 @@ class GettraceTest(CoverageTest):
)
@pytest.mark.expensive
- def test_atexit_gettrace(self):
+ def test_atexit_gettrace(self): # pragma: not covered
# This is not a test of coverage at all, but of our understanding
# of this edge-case behavior in various Pythons.
if env.METACOV: