[diffoscope] 04/05: tests.comparators: Add test for symlink differing in destination.

Chris Lamb chris at chris-lamb.co.uk
Thu Feb 2 03:51:25 CET 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository diffoscope.

commit 8046db92916e147a7bb936608e6efb197b45c955
Author: Chris Lamb <lamby at debian.org>
Date:   Thu Feb 2 14:59:03 2017 +1300

    tests.comparators: Add test for symlink differing in destination.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 tests/comparators/test_symlink.py            | 39 ++++++++++++++++++++++++++++
 tests/data/symlink_expected_destination_diff |  3 +++
 2 files changed, 42 insertions(+)

diff --git a/tests/comparators/test_symlink.py b/tests/comparators/test_symlink.py
new file mode 100644
index 0000000..d470b79
--- /dev/null
+++ b/tests/comparators/test_symlink.py
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+#
+# diffoscope: in-depth comparison of files, archives, and directories
+#
+# Copyright © 2017 Chris Lamb <lamby at debian.org>
+#
+# diffoscope is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# diffoscope is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
+
+import os
+
+from diffoscope.comparators.binary import FilesystemFile
+from diffoscope.comparators.utils.specialize import specialize
+
+from utils.data import data
+
+
+def test_destination(tmpdir):
+    def create(x):
+        path = os.path.join(str(tmpdir.mkdir(x)), 'src')
+        os.symlink('/{}'.format(x), path)
+        return specialize(FilesystemFile(path))
+
+    a = create('a')
+    b = create('b')
+
+    expected_diff = open(data('symlink_expected_destination_diff')).read()
+
+    assert a.compare(b).unified_diff == expected_diff
diff --git a/tests/data/symlink_expected_destination_diff b/tests/data/symlink_expected_destination_diff
new file mode 100644
index 0000000..37f6325
--- /dev/null
+++ b/tests/data/symlink_expected_destination_diff
@@ -0,0 +1,3 @@
+@@ -1 +1 @@
+-destination: /a
++destination: /b

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list