summaryrefslogtreecommitdiff
path: root/tests/goldtest.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-07-15 09:39:31 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-07-15 09:39:31 -0400
commitc0da97eb03d4ffe8be8854ad6ff1a2736f169003 (patch)
tree971b019f78a5f1f2118dd5d46b5edb7937661a1f /tests/goldtest.py
parent4d05ddeeded7f3f594c0614630f467e1bf3fa629 (diff)
downloadpython-coveragepy-git-c0da97eb03d4ffe8be8854ad6ff1a2736f169003.tar.gz
test: change how we keep mismatched actual output
Now when a goldtest has a failure, the actual mismatched output will be written to the tests/actual directory. Along the way, I removed some obsolete settings which were only used by unittest and unittest_mixins, which we no longer use: - COVERAGE_KEEP_TMP - COVERAGE_ENV_ID - $TMPDIR/coverage_test
Diffstat (limited to 'tests/goldtest.py')
-rw-r--r--tests/goldtest.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/goldtest.py b/tests/goldtest.py
index b9d59217..96d3cf81 100644
--- a/tests/goldtest.py
+++ b/tests/goldtest.py
@@ -67,6 +67,14 @@ def compare(
expected_only = fnmatch_list(dc.left_only, file_pattern)
actual_only = fnmatch_list(dc.right_only, file_pattern)
+ def save_mismatch(f):
+ """Save a mismatched result to tests/actual."""
+ save_path = expected_dir.replace("/gold/", "/actual/")
+ os.makedirs(save_path, exist_ok=True)
+ with open(os.path.join(save_path, f), "w") as savef:
+ with open(os.path.join(actual_dir, f)) as readf:
+ savef.write(readf.read())
+
# filecmp only compares in binary mode, but we want text mode. So
# look through the list of different files, and compare them
# ourselves.
@@ -95,6 +103,12 @@ def compare(
print(f":::: diff {expected_file!r} and {actual_file!r}")
print("\n".join(difflib.Differ().compare(expected, actual)))
print(f":::: end diff {expected_file!r} and {actual_file!r}")
+ save_mismatch(f)
+
+ if not actual_extra:
+ for f in actual_only:
+ save_mismatch(f)
+
assert not text_diff, "Files differ: %s" % '\n'.join(text_diff)
assert not expected_only, f"Files in {expected_dir} only: {expected_only}"