[Reproducible-commits] [debbindiff] 03/03: Add tests for directory comparator

Jérémy Bobbio lunar at moszumanska.debian.org
Thu Jun 25 09:52:24 UTC 2015


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

lunar pushed a commit to branch master
in repository debbindiff.

commit b6d50a3e13ca0fe28de6c3886d9970a4966806d4
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Thu Jun 25 09:52:11 2015 +0000

    Add tests for directory comparator
---
 tests/comparators/test_directory.py | 59 +++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/tests/comparators/test_directory.py b/tests/comparators/test_directory.py
new file mode 100644
index 0000000..bce2e9f
--- /dev/null
+++ b/tests/comparators/test_directory.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# debbindiff: highlight differences between two builds of Debian packages
+#
+# Copyright © 2015 Jérémy Bobbio <lunar at debian.org>
+#
+# debbindiff 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.
+#
+# debbindiff 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 debbindiff.  If not, see <http://www.gnu.org/licenses/>.
+
+from __future__ import print_function
+
+import os
+import os.path
+import shutil
+import pytest
+import debbindiff.comparators.binary
+from debbindiff.comparators.directory import compare_directories
+from debbindiff.presenters.text import output_text
+
+TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/text_ascii1') 
+TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/text_ascii2') 
+
+def test_no_differences():
+    differences = compare_directories(os.path.dirname(__file__), os.path.dirname(__file__))
+    output_text(differences, print_func=print)
+    assert len(differences) == 0
+
+ at pytest.fixture
+def differences(tmpdir):
+    tmpdir.mkdir('a')
+    tmpdir.mkdir('a/dir')
+    tmpdir.mkdir('b')
+    tmpdir.mkdir('b/dir')
+    shutil.copy(TEST_FILE1_PATH, str(tmpdir.join('a/dir/text')))
+    shutil.copy(TEST_FILE2_PATH, str(tmpdir.join('b/dir/text')))
+    os.utime(str(tmpdir.join('a/dir/text')), (0, 0))
+    os.utime(str(tmpdir.join('b/dir/text')), (0, 0))
+    return compare_directories(str(tmpdir.join('a')), str(tmpdir.join('b')))
+
+def test_content(differences):
+    assert differences[0].details[0].source1 == 'dir'
+    assert differences[0].details[0].details[0].source1 == 'text'
+    expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/text_ascii_expected_diff')).read()
+    assert differences[0].details[0].details[0].unified_diff == expected_diff
+
+def test_stat(differences):
+    output_text(differences, print_func=print)
+    assert 'stat' in differences[0].details[0].details[0].details[0].source1

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



More information about the Reproducible-commits mailing list