Commit 571b9d46 authored by Jérémy Bobbio's avatar Jérémy Bobbio

Add tests for cpio comparator

parent 5cdf64b2
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# debbindiff: highlight differences between two builds of Debian packages
#
# Copyright © 2015 Jérémy Bobbio <lunar@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/>.
import codecs
import os.path
import shutil
import pytest
from debbindiff.comparators.cpio import compare_cpio_files
TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.cpio')
TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.cpio')
def test_no_differences():
differences = compare_cpio_files(TEST_FILE1_PATH, TEST_FILE1_PATH)
assert len(differences) == 0
@pytest.fixture
def differences():
return compare_cpio_files(TEST_FILE1_PATH, TEST_FILE2_PATH)[0].details # skip container with path
def test_listing(differences):
expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/cpio_listing_expected_diff')).read()
assert differences[0].unified_diff == expected_diff
def test_compressed_files(differences):
assert differences[1].source1 == 'dir/text'
assert differences[1].source2 == 'dir/text'
expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/text_ascii_expected_diff')).read()
assert differences[1].unified_diff == expected_diff
@@ -1,4 +1,4 @@
-lrwxrwxrwx 1 lunar lunar 6 Jun 24 15:10 dir/link -> broken
+lrwxrwxrwx 1 lunar lunar 13 Jun 24 15:11 dir/link -> really-broken
crw-r--r-- 1 root root 1, 3 Jun 24 14:47 dir/null
--rw-r--r-- 1 lunar lunar 446 Jun 24 15:10 dir/text
-drwxr-xr-x 2 lunar lunar 0 Jun 24 15:10 dir
+-rw-r--r-- 1 lunar lunar 671 Jun 24 15:11 dir/text
+drwxr-xr-x 2 lunar lunar 0 Jun 24 15:11 dir
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment