diff options
author | Tzu-ping Chung <uranusjr@gmail.com> | 2014-09-09 17:14:38 +0800 |
---|---|---|
committer | Tzu-ping Chung <uranusjr@gmail.com> | 2014-09-09 17:14:38 +0800 |
commit | 6510aa4b76de4aa577d5cf394e8e629857052853 (patch) | |
tree | 7bb658eaffedb20e9d7a95afdc0a090a85dac8be /test | |
parent | 95ab7bb92fbe8230c96b3513a4714b61bb52bbb9 (diff) | |
download | rust-hoedown-6510aa4b76de4aa577d5cf394e8e629857052853.tar.gz |
Use difflib to make error friendly
Diffstat (limited to 'test')
-rwxr-xr-x | test/runner.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/test/runner.py b/test/runner.py index fb64375..6951d1d 100755 --- a/test/runner.py +++ b/test/runner.py @@ -24,13 +24,9 @@ SLUGIFY_PATTERN = re.compile(r'\W') class TestFailed(AssertionError): def __init__(self, name, expected, got): super(TestFailed, self).__init__(self) - description_format = ( - '{name}\nExpected\n{sln}\n{expected}\n\n' - 'Got\n{sln}\n{got}\n\n' - ) - self.description = description_format.format( - dln=DLN, sln=SLN, name=name, - expected=expected.strip(), got=got.strip(), + diff = difflib.unified_diff(expected.splitlines(), got.splitlines(), 'Expected', 'Got') + self.description = '{name}\n{diff}'.format( + name=name, diff='\n'.join(diff), ) def __str__(self): @@ -48,14 +44,14 @@ def _test_func(test_case): TIDY, stdin=hoedown_proc.stdout, stdout=subprocess.PIPE, ) got_tidy_proc.wait() - got = got_tidy_proc.stdout.read() + got = got_tidy_proc.stdout.read().strip() expected_tidy_proc = subprocess.Popen( TIDY + [os.path.join(TEST_ROOT, test_case['output'])], stdout=subprocess.PIPE, ) expected_tidy_proc.wait() - expected = expected_tidy_proc.stdout.read() + expected = expected_tidy_proc.stdout.read().strip() try: assert expected == got |