Loading tests/comparators/test_python.py +2 −3 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ import sys from diffoscope.comparators.python import PycFile from ..utils.data import assert_diff, load_fixture from ..utils.data import assert_diff_startswith, load_fixture pyc1 = load_fixture("test1.pyc-renamed") Loading @@ -47,8 +47,7 @@ def differences(pyc1, pyc2): def test_diff(differences): assert_diff( assert_diff_startswith( differences[0], "pyc_expected_diff", lambda haystack, needle: haystack.startswith(needle), ) tests/utils/data.py +8 −2 Original line number Diff line number Diff line Loading @@ -56,12 +56,18 @@ def get_data(filename): return f.read() def assert_diff(difference, filename, cmp=lambda x, y: x == y): def assert_diff(difference, filename): # Assign seen and expected values to local variables to improve contextual # information in failed tests. seen = difference.unified_diff expected = get_data(filename) assert cmp(seen, expected) assert seen == expected def assert_diff_startswith(difference, filename): haystack = difference.unified_diff needle = get_data(filename) assert needle.startswith(haystack) # https://code.activestate.com/recipes/576620-changedirectory-context-manager/#c3 Loading Loading
tests/comparators/test_python.py +2 −3 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ import sys from diffoscope.comparators.python import PycFile from ..utils.data import assert_diff, load_fixture from ..utils.data import assert_diff_startswith, load_fixture pyc1 = load_fixture("test1.pyc-renamed") Loading @@ -47,8 +47,7 @@ def differences(pyc1, pyc2): def test_diff(differences): assert_diff( assert_diff_startswith( differences[0], "pyc_expected_diff", lambda haystack, needle: haystack.startswith(needle), )
tests/utils/data.py +8 −2 Original line number Diff line number Diff line Loading @@ -56,12 +56,18 @@ def get_data(filename): return f.read() def assert_diff(difference, filename, cmp=lambda x, y: x == y): def assert_diff(difference, filename): # Assign seen and expected values to local variables to improve contextual # information in failed tests. seen = difference.unified_diff expected = get_data(filename) assert cmp(seen, expected) assert seen == expected def assert_diff_startswith(difference, filename): haystack = difference.unified_diff needle = get_data(filename) assert needle.startswith(haystack) # https://code.activestate.com/recipes/576620-changedirectory-context-manager/#c3 Loading