Commits (2)
......@@ -116,11 +116,11 @@ class Difference:
raise NotImplementedError(
"_reverse_self on VisualDifference is not yet implemented"
)
unified_diff = (
reverse_unified_diff(self.unified_diff)
if self.unified_diff is not None
else None
)
unified_diff = None
if self.unified_diff is not None:
unified_diff = reverse_unified_diff(self.unified_diff)
return self.__class__(
self.source2,
self.source1,
......
......@@ -111,3 +111,16 @@ def test_compare_to_dangling_symlink(tmpdir):
b = specialize(FilesystemFile(path))
assert a.compare(b).unified_diff == get_data("test_directory_symlink_diff")
@pytest.mark.xfail(strict=False)
def test_compare_both_ways(tmpdir):
"""
Comparing a directory with a file shouldn't crash, but nor should as
comparing a file with a directory either. (Re: #292)
"""
a = specialize(FilesystemFile(str(tmpdir)))
b = specialize(FilesystemFile(TEST_FILE1_PATH))
a.compare(b)
b.compare(a)