Skip to content

Commit 5f874a2

Browse files
committed
Improve error message on failing test_pyplot_up_to_date
1 parent fbd0fba commit 5f874a2

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/matplotlib/tests/test_pyplot.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import difflib
12
import subprocess
23
import sys
34
from pathlib import Path
@@ -16,7 +17,19 @@ def test_pyplot_up_to_date():
1617
try:
1718
subprocess.run([sys.executable, str(gen_script)], check=True)
1819
new_contents = Path(plt.__file__).read_text()
19-
assert orig_contents == new_contents
20+
21+
if orig_contents != new_contents:
22+
diff_msg = '\n'.join(
23+
difflib.unified_diff(
24+
orig_contents.split('\n'), new_contents.split('\n'),
25+
fromfile='found pyplot.py',
26+
tofile='expected pyplot.py',
27+
n=0, lineterm=''))
28+
raise AssertionError(
29+
"pyplot.py is not up-to-date. Please rerun "
30+
"'python pytools/boilerplate.py' to update pyplot.py. "
31+
"Here is a diff of unexpected differences:\n%s" % diff_msg
32+
)
2033
finally:
2134
Path(plt.__file__).write_text(orig_contents)
2235

0 commit comments

Comments
 (0)