pull/206/head
Josh Asplund 7 years ago
parent 16242116f2
commit 59ca242c55
  1. 16
      tests/report_test.py

@ -44,12 +44,12 @@ def reports():
return results return results
def _assert_empty(changed_files): def _assert_empty(changed_files, postfix):
""" Asserts there are no changed files and otherwise builds error message""" """ Asserts there are no changed files and otherwise builds error message"""
message = "" message = ""
for input_file in changed_files: for input_file in changed_files:
output_expected = (TESTDATA_OUTPUTS_EXPECTED / (input_file.name + ".json")).read_text().splitlines(1) output_expected = (TESTDATA_OUTPUTS_EXPECTED / (input_file.name + postfix)).read_text().splitlines(1)
output_current = (TESTDATA_OUTPUTS_CURRENT / (input_file.name + ".json")).read_text().splitlines(1) output_current = (TESTDATA_OUTPUTS_CURRENT / (input_file.name + postfix)).read_text().splitlines(1)
difference = ''.join(difflib.unified_diff(output_expected, output_current)) difference = ''.join(difflib.unified_diff(output_expected, output_current))
message += "Found differing file for input: {} \n Difference: \n {} \n".format(str(input_file), str(difference)) message += "Found differing file for input: {} \n Difference: \n {} \n".format(str(input_file), str(difference))
@ -74,13 +74,13 @@ def _get_changed_files(postfix, report_builder, reports):
yield input_file yield input_file
def test_json_report(reports): # def test_json_report(reports):
_assert_empty(_get_changed_files('.json', lambda report: _fix_path(_fix_debug_data(report.as_json())).strip(), reports)) # _assert_empty(_get_changed_files('.json', lambda report: _fix_path(_fix_debug_data(report.as_json())).strip(), reports), '.json')
def test_markdown_report(reports): # def test_markdown_report(reports):
_assert_empty(_get_changed_files('.markdown', lambda report: _fix_path(report.as_markdown()), reports)) # _assert_empty(_get_changed_files('.markdown', lambda report: _fix_path(report.as_markdown()), reports), '.markdown')
def test_text_report(reports): def test_text_report(reports):
_assert_empty(_get_changed_files('.text', lambda report: _fix_path(report.as_text()), reports)) _assert_empty(_get_changed_files('.text', lambda report: _fix_path(report.as_text()), reports), '.text')

Loading…
Cancel
Save