Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make docs/cookbook/test_recipes.py ignore whitespace differences #2280

Merged
merged 1 commit into from
Mar 31, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions docs/cookbook/test_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import os
import glob
import subprocess
import difflib
import re


# print start time
Expand All @@ -32,16 +32,12 @@
res_filename = recipe.replace('.py', '.res')
with open(res_filename, 'r') as resfile:
exp = resfile.read()
# check for differences between out and exp results
actual = out.splitlines(True)
expect = exp.splitlines(True)
diff_lines = list()
diff = difflib.unified_diff(expect, actual,
fromfile='expect', tofile='actual', n=0)
for line in diff:
diff_lines.append(line)
# check for differences between out and exp results ignoring whitespace
actual = re.sub(r'\s', '', out)
expect = re.sub(r'\s', '', exp)
differences = actual != expect
# write actual output to file if any differences; else report PASS
if diff_lines:
if differences:
with open(out_filename, 'w') as outfile:
outfile.write(out)
msg = '{} FAIL : actual in {} & expected in {}'
Expand Down