diff options
Diffstat (limited to 'test')
-rwxr-xr-x | test/spec_tests.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/test/spec_tests.py b/test/spec_tests.py index c191ef0..a595381 100755 --- a/test/spec_tests.py +++ b/test/spec_tests.py @@ -39,8 +39,13 @@ def do_test(test, normalize, result_counts): [retcode, actual_html, err] = cmark.to_html(test['markdown']) if retcode == 0: expected_html = test['html'] + unicode_error = None if normalize: - passed = normalize_html(actual_html) == normalize_html(expected_html) + try: + passed = normalize_html(actual_html) == normalize_html(expected_html) + except UnicodeDecodeError, e: + unicode_error = e + passed = False else: passed = actual_html == expected_html if passed: @@ -48,11 +53,16 @@ def do_test(test, normalize, result_counts): else: print_test_header(test['section'], test['example'], test['start_line'], test['end_line']) sys.stdout.write(test['markdown']) - expected_html_lines = expected_html.splitlines(True) - actual_html_lines = actual_html.splitlines(True) - for diffline in unified_diff(expected_html_lines, actual_html_lines, - "expected HTML", "actual HTML"): - sys.stdout.write(diffline) + if unicode_error: + print "Unicode error: " + str(unicode_error) + print "Expected: " + repr(expected_html) + print "Got: " + repr(actual_html) + else: + expected_html_lines = expected_html.splitlines(True) + actual_html_lines = actual_html.splitlines(True) + for diffline in unified_diff(expected_html_lines, actual_html_lines, + "expected HTML", "actual HTML"): + sys.stdout.write(diffline) sys.stdout.write('\n') result_counts['fail'] += 1 else: |