diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2018-06-26 21:09:52 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2018-06-26 21:09:52 -0400 |
commit | 2d8116ef308f205df4b7091f93ae5930bdfe345b (patch) | |
tree | 1e80c824d0e5dd46519b7da4ed8730a26b8518f4 | |
parent | 7a099a2204e6863824f11432c807442f3ad5306c (diff) | |
parent | db8b6053fd7004d8ef041f6e6ac40c96ae7d17e3 (diff) | |
download | python-coveragepy-git-2d8116ef308f205df4b7091f93ae5930bdfe345b.tar.gz |
some minor improvements for the farm tests
-rw-r--r-- | tests/test_farm.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/tests/test_farm.py b/tests/test_farm.py index 892d2393..c9969c85 100644 --- a/tests/test_farm.py +++ b/tests/test_farm.py @@ -104,7 +104,7 @@ class FarmTestCase(ModuleAwareMixin, SysPathAwareMixin, unittest.TestCase): raise Exception("runTest isn't used in this class!") def __call__(self): # pylint: disable=arguments-differ - """Execute the test from the run.py file.""" + """Execute the test from the runpy file.""" if _TEST_NAME_FILE: # pragma: debugging with open(_TEST_NAME_FILE, "w") as f: f.write(self.description.replace("/", "_")) @@ -147,6 +147,8 @@ def noop(*args_unused, **kwargs_unused): def copy(src, dst): """Copy a directory.""" + if os.path.exists(dst): + pytest.fail('%s already exists.' % os.path.join(os.getcwd(), dst)) shutil.copytree(src, dst) @@ -234,19 +236,21 @@ def compare(dir1, dir2, file_pattern=None, size_within=0, left_extra=False, scru # ourselves. text_diff = [] for f in diff_files: - with open(os.path.join(dir1, f), READ_MODE) as fobj: + left_file = os.path.join(dir1, f) + right_file = os.path.join(dir2, f) + with open(left_file, READ_MODE) as fobj: left = fobj.read() - with open(os.path.join(dir2, f), READ_MODE) as fobj: + with open(right_file, READ_MODE) as fobj: right = fobj.read() if scrubs: left = scrub(left, scrubs) right = scrub(right, scrubs) if left != right: # pragma: only failure - text_diff.append(f) + text_diff.append('%s != %s' % (left_file, right_file)) left = left.splitlines() right = right.splitlines() print("\n".join(difflib.Differ().compare(left, right))) - assert not text_diff, "Files differ: %s" % text_diff + assert not text_diff, "Files differ: %s" % '\n'.join(text_diff) if not left_extra: assert not left_only, "Files in %s only: %s" % (dir1, left_only) |