[diffoscope] 02/02: Add GitIndex tests to bring coverage of comparators/git.py to 100%.

Chris Lamb chris at chris-lamb.co.uk
Sat Aug 20 12:46:20 CEST 2016


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

lamby pushed a commit to branch master
in repository diffoscope.

commit 9cef91fc49e04357d4e83110dc03790d48b7eb1a
Author: Chris Lamb <lamby at debian.org>
Date:   Sat Aug 20 11:41:10 2016 +0100

    Add GitIndex tests to bring coverage of comparators/git.py to 100%.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 tests/comparators/test_git.py |  52 ++++++++++++++++++++++++++++++++++++++++++
 tests/data/git_expected_diff  |  19 +++++++++++++++
 tests/data/test1.git-index    | Bin 0 -> 129 bytes
 tests/data/test2.git-index    | Bin 0 -> 193 bytes
 4 files changed, 71 insertions(+)

diff --git a/tests/comparators/test_git.py b/tests/comparators/test_git.py
new file mode 100644
index 0000000..b4c3bc7
--- /dev/null
+++ b/tests/comparators/test_git.py
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+#
+# diffoscope: in-depth comparison of files, archives, and directories
+#
+# Copyright © 2016 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 <http://www.gnu.org/licenses/>.
+
+import pytest
+
+from diffoscope.comparators import specialize
+from diffoscope.comparators.git import GitIndexFile
+from diffoscope.comparators.binary import FilesystemFile
+
+from conftest import data
+
+TEST_FILE1_PATH = data('test1.git-index')
+TEST_FILE2_PATH = data('test2.git-index')
+
+ at pytest.fixture
+def git1():
+    return specialize(FilesystemFile(TEST_FILE1_PATH))
+
+ at pytest.fixture
+def git2():
+    return specialize(FilesystemFile(TEST_FILE2_PATH))
+
+def test_identification(git1):
+    assert isinstance(git1, GitIndexFile)
+
+def test_no_differences(git1):
+    assert git1.compare(git1) is None
+
+ at pytest.fixture
+def differences(git1, git2):
+    return git1.compare(git2).details
+
+def test_diff(differences):
+    with open(data('git_expected_diff')) as f:
+        expected_diff = f.read()
+    assert differences[0].unified_diff == expected_diff
diff --git a/tests/data/git_expected_diff b/tests/data/git_expected_diff
new file mode 100644
index 0000000..dfddbaf
--- /dev/null
+++ b/tests/data/git_expected_diff
@@ -0,0 +1,19 @@
+@@ -10,7 +10,18 @@
+ User ID:   1000
+ Group ID:  1000
+ Created:   1471689380.154572964
+ Modified:  1471689380.154572964
+ Inode:     52205983
+ Device ID: (8, 6)
+ 
++Path:      b'b'
++SHA:       e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
++Size:      0
++Flags:     0b1
++User ID:   1000
++Group ID:  1000
++Created:   1471689417.184218147
++Modified:  1471689417.184218147
++Inode:     52206041
++Device ID: (8, 6)
++
diff --git a/tests/data/test1.git-index b/tests/data/test1.git-index
new file mode 100644
index 0000000..6e19fd6
Binary files /dev/null and b/tests/data/test1.git-index differ
diff --git a/tests/data/test2.git-index b/tests/data/test2.git-index
new file mode 100644
index 0000000..998078d
Binary files /dev/null and b/tests/data/test2.git-index differ

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


More information about the diffoscope mailing list