summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/helpers.py4
-rw-r--r--tests/test_farm.py27
-rw-r--r--tests/test_oddball.py18
-rw-r--r--tests/test_phystokens.py2
4 files changed, 12 insertions, 39 deletions
diff --git a/tests/helpers.py b/tests/helpers.py
index 344ed71e..cbb6e01c 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -26,9 +26,7 @@ def run_command(cmd):
# the subprocess is set incorrectly to ascii. Use an environment variable
# to force the encoding to be the same as ours.
sub_env = dict(os.environ)
- encoding = output_encoding()
- if encoding:
- sub_env['PYTHONIOENCODING'] = encoding
+ sub_env['PYTHONIOENCODING'] = output_encoding()
proc = subprocess.Popen(
cmd,
diff --git a/tests/test_farm.py b/tests/test_farm.py
index 8e497363..6f38e5b4 100644
--- a/tests/test_farm.py
+++ b/tests/test_farm.py
@@ -147,8 +147,6 @@ def noop(*args_unused, **kwargs_unused):
def copy(src, dst):
"""Copy a directory."""
- if os.path.exists(dst):
- shutil.rmtree(dst)
shutil.copytree(src, dst)
@@ -179,17 +177,9 @@ def run(cmds, rundir="src", outfile=None):
fout.close()
-def compare(
- dir1, dir2, file_pattern=None, size_within=0,
- left_extra=False, right_extra=False, scrubs=None
-):
+def compare(dir1, dir2, file_pattern=None, size_within=0, left_extra=False, scrubs=None):
"""Compare files matching `file_pattern` in `dir1` and `dir2`.
- `dir2` is interpreted as a prefix, with Python version numbers appended
- to find the actual directory to compare with. "foo" will compare
- against "foo_v241", "foo_v24", "foo_v2", or "foo", depending on which
- directory is found first.
-
`size_within` is a percentage delta for the file sizes. If non-zero,
then the file contents are not compared (since they are expected to
often be different), but the file sizes must be within this amount.
@@ -197,8 +187,7 @@ def compare(
within 10 percent of each other to compare equal.
`left_extra` true means the left directory can have extra files in it
- without triggering an assertion. `right_extra` means the right
- directory can.
+ without triggering an assertion.
`scrubs` is a list of pairs, regexes to find and literal strings to
replace them with to scrub the files of unimportant differences.
@@ -207,15 +196,6 @@ def compare(
matches.
"""
- # Search for a dir2 with a version suffix.
- version_suff = ''.join(map(str, sys.version_info[:3]))
- while version_suff:
- trydir = dir2 + '_v' + version_suff
- if os.path.exists(trydir):
- dir2 = trydir
- break
- version_suff = version_suff[:-1]
-
assert os.path.exists(dir1), "Left directory missing: %s" % dir1
assert os.path.exists(dir2), "Right directory missing: %s" % dir2
@@ -270,8 +250,7 @@ def compare(
if not left_extra:
assert not left_only, "Files in %s only: %s" % (dir1, left_only)
- if not right_extra:
- assert not right_only, "Files in %s only: %s" % (dir2, right_only)
+ assert not right_only, "Files in %s only: %s" % (dir2, right_only)
def contains(filename, *strlist):
diff --git a/tests/test_oddball.py b/tests/test_oddball.py
index 1cdadf6f..5a331a29 100644
--- a/tests/test_oddball.py
+++ b/tests/test_oddball.py
@@ -119,7 +119,7 @@ class RecursionTest(CoverageTest):
pytrace = (cov.collector.tracer_name() == "PyTracer")
expected_missing = [3]
- if pytrace:
+ if pytrace: # pragma: no metacov
expected_missing += [9, 10, 11]
_, statements, missing, _ = cov.analysis("recur.py")
@@ -127,7 +127,7 @@ class RecursionTest(CoverageTest):
self.assertEqual(missing, expected_missing)
# Get a warning about the stackoverflow effect on the tracing function.
- if pytrace:
+ if pytrace: # pragma: no metacov
self.assertEqual(cov._warnings,
["Trace function changed, measurement is likely wrong: None"]
)
@@ -400,15 +400,11 @@ class DoctestTest(CoverageTest):
def setUp(self):
super(DoctestTest, self).setUp()
- # Oh, the irony! This test case exists because Python 2.4's
- # doctest module doesn't play well with coverage. But nose fixes
- # the problem by monkeypatching doctest. I want to undo the
- # monkeypatch to be sure I'm getting the doctest module that users
- # of coverage will get. Deleting the imported module here is
- # enough: when the test imports doctest again, it will get a fresh
- # copy without the monkeypatch.
- if 'doctest' in sys.modules:
- del sys.modules['doctest']
+ # This test case exists because Python 2.4's doctest module didn't play
+ # well with coverage. Nose fixes the problem by monkeypatching doctest.
+ # I want to be sure there's no monkeypatch and that I'm getting the
+ # doctest module that users of coverage will get.
+ assert 'doctest' not in sys.modules
def test_doctest(self):
self.check_coverage('''\
diff --git a/tests/test_phystokens.py b/tests/test_phystokens.py
index 15c6cb3a..d43b630f 100644
--- a/tests/test_phystokens.py
+++ b/tests/test_phystokens.py
@@ -128,7 +128,7 @@ class SourceEncodingTest(CoverageTest):
)
def test_detect_source_encoding_not_in_comment(self):
- if env.PYPY and env.PY3:
+ if env.PYPY and env.PY3: # pramga: no metacov
# PyPy3 gets this case wrong. Not sure what I can do about it,
# so skip the test.
self.skipTest("PyPy3 is wrong about non-comment encoding. Skip it.")