summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-07-07 14:33:25 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-07-07 14:33:25 -0700
commit7bd74a60747c2c49f5bd498707be5c4a3313842e (patch)
treec8bebf822d60c792601221212a3afa37ab5d0ea7
parent8011e3a9e68262db3a05977d58be25fe2d171954 (diff)
Updated spec_tests.py from jgm/CommonMark.
This forces utf-8 encoding.
-rwxr-xr-xtest/spec_tests.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/test/spec_tests.py b/test/spec_tests.py
index be11f12..11b271c 100755
--- a/test/spec_tests.py
+++ b/test/spec_tests.py
@@ -52,7 +52,7 @@ def do_test(test, normalize, result_counts):
result_counts['pass'] += 1
else:
print_test_header(test['section'], test['example'], test['start_line'], test['end_line'])
- sys.stdout.write(test['markdown'])
+ sys.stdout.buffer.write(test['markdown'].encode('utf-8'))
if unicode_error:
print("Unicode error: " + str(unicode_error))
print("Expected: " + repr(expected_html))
@@ -62,7 +62,7 @@ def do_test(test, normalize, result_counts):
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.buffer.write(diffline.encode('utf-8'))
sys.stdout.write('\n')
result_counts['fail'] += 1
else:
@@ -124,7 +124,7 @@ if __name__ == "__main__":
pattern_re = re.compile('.')
tests = [ test for test in all_tests if re.search(pattern_re, test['section']) and (not args.number or test['example'] == args.number) ]
if args.dump_tests:
- print(json.dumps(tests, ensure_ascii=False, indent=2))
+ sys.stdout.buffer.write(json.dumps(tests, ensure_ascii=False, indent=2).encode('utf-8'))
exit(0)
else:
skipped = len(all_tests) - len(tests)