[diffoscope] 04/05: Fix tests that call xxd fail on jessie due to output change. (Closes: #855239)
Mattia Rizzolo
mattia at debian.org
Mon Feb 20 19:53:13 CET 2017
This is an automated email from the git hooks/post-receive script.
mattia pushed a commit to annotated tag 77_bpo8+1
in repository diffoscope.
commit 9145f206cbe75b45efa41bf3c324a7e859c85a5e
Author: Chris Lamb <lamby at debian.org>
Date: Sat Feb 18 14:44:09 2017 +1300
Fix tests that call xxd fail on jessie due to output change. (Closes: #855239)
---
tests/comparators/test_device.py | 6 +++---
tests/comparators/test_rpm.py | 4 ++--
tests/comparators/utils/data.py | 11 +++++++++--
3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/tests/comparators/test_device.py b/tests/comparators/test_device.py
index 4ab1710..9866e40 100644
--- a/tests/comparators/test_device.py
+++ b/tests/comparators/test_device.py
@@ -23,7 +23,7 @@ from diffoscope.comparators.binary import FilesystemFile
from diffoscope.comparators.device import Device
from diffoscope.comparators.utils.specialize import specialize
-from utils.data import load_fixture, get_data
+from utils.data import load_fixture, get_data, normalize_zeros
from utils.tools import skip_unless_tools_exist
@@ -47,9 +47,9 @@ def test_identification(devnull):
@skip_unless_tools_exist('xxd')
def test_diff(differences):
expected_diff = get_data('device_expected_diff')
- assert differences.unified_diff == expected_diff
+ assert normalize_zeros(differences.unified_diff) == expected_diff
@skip_unless_tools_exist('xxd')
def test_diff_reverse(differences_reverse):
expected_diff = get_data('device_expected_diff_reverse')
- assert differences_reverse.unified_diff == expected_diff
+ assert normalize_zeros(differences_reverse.unified_diff) == expected_diff
diff --git a/tests/comparators/test_rpm.py b/tests/comparators/test_rpm.py
index 0c13fd2..c374714 100644
--- a/tests/comparators/test_rpm.py
+++ b/tests/comparators/test_rpm.py
@@ -23,7 +23,7 @@ from diffoscope.comparators import ComparatorManager
from diffoscope.comparators.binary import FilesystemFile
from diffoscope.comparators.utils.specialize import specialize
-from utils.data import load_fixture, data, get_data
+from utils.data import load_fixture, data, get_data, normalize_zeros
from utils.tools import skip_unless_tools_exist, skip_unless_module_exists
from utils.nonexisting import assert_non_existing
@@ -92,4 +92,4 @@ def test_fallback_comparison(monkeypatch):
assert rpm2.compare(rpm2) is None
expected_diff = get_data('rpm_fallback_expected_diff')
- assert rpm1.compare(rpm2).unified_diff == expected_diff
+ assert normalize_zeros(rpm1.compare(rpm2).unified_diff) == expected_diff
diff --git a/tests/comparators/utils/data.py b/tests/comparators/utils/data.py
index 23464c7..b815235 100644
--- a/tests/comparators/utils/data.py
+++ b/tests/comparators/utils/data.py
@@ -19,11 +19,16 @@
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import os
+import re
import pytest
from diffoscope.comparators.binary import FilesystemFile
from diffoscope.comparators.utils.specialize import specialize
+re_normalize_zeros = re.compile(
+ r'^(?P<prefix>[ \-\+])(?P<offset>[0-9a-f]+)(?=: )', re.MULTILINE,
+)
+
def init_fixture(filename):
return pytest.fixture(
@@ -50,5 +55,7 @@ def load_fixture(filename):
def normalize_zeros(s):
- # older xxd had one zero less. Make sure there are always 8.
- return s.replace('-0000000:', '-00000000:').replace('+0000000:', '+00000000:')
+ # older xxd had one zero less.a Make sure there are always 8.
+ def repl(x):
+ return '{}{:08x}'.format(x.group('prefix'), int(x.group('offset'), 16))
+ return re_normalize_zeros.sub(repl, s)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list