[diffoscope] 02/05: tests.comparators: Avoid DRY violations by using new 'get_data' method.

Chris Lamb chris at chris-lamb.co.uk
Thu Feb 2 02:51:39 UTC 2017


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

lamby pushed a commit to branch master
in repository diffoscope.

commit 03446b88d9fc32c7e021be1e4ddd5488924ddbf6
Author: Chris Lamb <lamby at debian.org>
Date:   Thu Feb 2 15:29:30 2017 +1300

    tests.comparators: Avoid DRY violations by using new 'get_data' method.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 tests/comparators/test_apk.py             |  6 +++---
 tests/comparators/test_binary.py          | 12 ++++++------
 tests/comparators/test_bzip2.py           |  4 ++--
 tests/comparators/test_cbfs.py            |  6 +++---
 tests/comparators/test_cpio.py            |  8 ++++----
 tests/comparators/test_deb.py             |  4 ++--
 tests/comparators/test_debian.py          |  8 ++++----
 tests/comparators/test_device.py          |  8 +++-----
 tests/comparators/test_dex.py             |  4 ++--
 tests/comparators/test_directory.py       |  4 ++--
 tests/comparators/test_elf.py             | 10 +++++-----
 tests/comparators/test_epub.py            |  4 ++--
 tests/comparators/test_fonts.py           |  4 ++--
 tests/comparators/test_fsimage.py         |  4 ++--
 tests/comparators/test_gettext.py         |  4 ++--
 tests/comparators/test_git.py             |  5 ++---
 tests/comparators/test_gzip.py            |  6 +++---
 tests/comparators/test_haskell.py         |  5 ++---
 tests/comparators/test_icc.py             |  4 ++--
 tests/comparators/test_ico_image.py       |  6 +++---
 tests/comparators/test_ipk.py             |  4 ++--
 tests/comparators/test_iso9660.py         | 10 +++++-----
 tests/comparators/test_java.py            |  4 ++--
 tests/comparators/test_javascript.py      |  4 ++--
 tests/comparators/test_jpeg_image.py      |  6 +++---
 tests/comparators/test_json.py            |  8 ++++----
 tests/comparators/test_macho.py           |  4 ++--
 tests/comparators/test_mono.py            |  4 ++--
 tests/comparators/test_openssh_pub_key.py |  4 ++--
 tests/comparators/test_pdf.py             |  6 +++---
 tests/comparators/test_png.py             |  4 ++--
 tests/comparators/test_ppu.py             |  4 ++--
 tests/comparators/test_ps.py              |  6 +++---
 tests/comparators/test_rlib.py            |  8 ++++----
 tests/comparators/test_rpm.py             |  8 ++++----
 tests/comparators/test_sqlite.py          |  4 ++--
 tests/comparators/test_squashfs.py        |  8 ++++----
 tests/comparators/test_symlink.py         |  4 ++--
 tests/comparators/test_tar.py             |  8 ++++----
 tests/comparators/test_text.py            |  6 +++---
 tests/comparators/test_xz.py              |  4 ++--
 tests/comparators/test_zip.py             | 10 +++++-----
 42 files changed, 120 insertions(+), 124 deletions(-)

diff --git a/tests/comparators/test_apk.py b/tests/comparators/test_apk.py
index e5f7f3b..77b3648 100644
--- a/tests/comparators/test_apk.py
+++ b/tests/comparators/test_apk.py
@@ -21,7 +21,7 @@ import pytest
 
 from diffoscope.comparators.apk import ApkFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 from utils.nonexisting import assert_non_existing
 
@@ -47,14 +47,14 @@ def test_compare_non_existing(monkeypatch, apk1):
 def test_zipinfo(differences):
     assert differences[0].source1 == 'zipinfo {}'
     assert differences[0].source2 == 'zipinfo {}'
-    expected_diff = open(data('apk_zipinfo_expected_diff')).read()
+    expected_diff = get_data('apk_zipinfo_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('apktool', 'zipinfo')
 def test_android_manifest(differences):
     assert differences[2].source1 == 'AndroidManifest.xml'
     assert differences[2].source2 == 'AndroidManifest.xml'
-    expected_diff = open(data('apk_manifest_expected_diff')).read()
+    expected_diff = get_data('apk_manifest_expected_diff')
     assert differences[2].unified_diff == expected_diff
 
 @skip_unless_tools_exist('apktool', 'zipinfo')
diff --git a/tests/comparators/test_binary.py b/tests/comparators/test_binary.py
index 2e64044..aee0e19 100644
--- a/tests/comparators/test_binary.py
+++ b/tests/comparators/test_binary.py
@@ -32,7 +32,7 @@ from diffoscope.comparators.utils.file import File
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.utils.compare import Xxd
 
-from utils.data import data, init_fixture
+from utils.data import data, init_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 
 
@@ -78,7 +78,7 @@ def test_no_differences_with_xxd(binary1):
 @skip_unless_tools_exist('xxd')
 def test_compare_with_xxd(binary1, binary2):
     difference = binary1.compare_bytes(binary2)
-    expected_diff = open(data('binary_expected_diff')).read()
+    expected_diff = get_data('binary_expected_diff')
     assert normalize_zeros(difference.unified_diff) == expected_diff
 
 def test_compare_non_existing_with_xxd(binary1):
@@ -97,7 +97,7 @@ def test_no_differences_without_xxd(xxd_not_found, binary1):
 
 def test_compare_without_xxd(xxd_not_found, binary1, binary2):
     difference = binary1.compare(binary2)
-    expected_diff = open(data('binary_hexdump_expected_diff')).read()
+    expected_diff = get_data('binary_hexdump_expected_diff')
     assert difference.unified_diff == expected_diff
 
 def test_with_compare_details():
@@ -114,7 +114,7 @@ def test_with_compare_details_and_fallback():
         def compare_details(self, other, source=None):
             return []
     difference = MockFile(TEST_FILE1_PATH).compare(MockFile(TEST_FILE2_PATH))
-    expected_diff = open(data('binary_expected_diff')).read()
+    expected_diff = get_data('binary_expected_diff')
     assert 'yet data differs' in difference.comment
     assert normalize_zeros(difference.unified_diff) == expected_diff
 
@@ -133,7 +133,7 @@ def test_with_compare_details_and_failed_process():
             subprocess.check_output(['sh', '-c', 'echo "%s"; exit 42' % output], shell=False)
             raise Exception('should not be run')
     difference = MockFile(TEST_FILE1_PATH).compare(MockFile(TEST_FILE2_PATH))
-    expected_diff = open(data('../data/binary_expected_diff')).read()
+    expected_diff = get_data('../data/binary_expected_diff')
     assert output in difference.comment
     assert '42' in difference.comment
     assert normalize_zeros(difference.unified_diff) == expected_diff
@@ -146,7 +146,7 @@ def test_with_compare_details_and_tool_not_found(monkeypatch):
         def compare_details(self, other, source=None):
             raise Exception('should not be run')
     difference = MockFile(TEST_FILE1_PATH).compare(MockFile(TEST_FILE2_PATH))
-    expected_diff = open(data('binary_expected_diff')).read()
+    expected_diff = get_data('binary_expected_diff')
     assert 'nonexistent' in difference.comment
     assert 'some-package' in difference.comment
     assert normalize_zeros(difference.unified_diff) == expected_diff
diff --git a/tests/comparators/test_bzip2.py b/tests/comparators/test_bzip2.py
index 57540e9..ce60b86 100644
--- a/tests/comparators/test_bzip2.py
+++ b/tests/comparators/test_bzip2.py
@@ -24,7 +24,7 @@ from diffoscope.comparators.bzip2 import Bzip2File
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 from utils.nonexisting import assert_non_existing
 
@@ -63,7 +63,7 @@ def test_content_source_without_extension(tmpdir, bzip1, bzip2):
 
 @skip_unless_tools_exist('bzip2')
 def test_content_diff(differences):
-    expected_diff = open(data('text_ascii_expected_diff')).read()
+    expected_diff = get_data('text_ascii_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('bzip2')
diff --git a/tests/comparators/test_cbfs.py b/tests/comparators/test_cbfs.py
index 49fa3fb..99ac699 100644
--- a/tests/comparators/test_cbfs.py
+++ b/tests/comparators/test_cbfs.py
@@ -25,7 +25,7 @@ from diffoscope.comparators.cbfs import CbfsFile
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils.data import data
+from utils.data import data, get_data
 from utils.tools import skip_unless_tools_exist
 from utils.nonexisting import assert_non_existing
 
@@ -76,14 +76,14 @@ def differences(rom1, rom2):
 
 @skip_unless_tools_exist('cbfstool')
 def test_listing(differences):
-    expected_diff = open(data('cbfs_listing_expected_diff')).read()
+    expected_diff = get_data('cbfs_listing_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('cbfstool')
 def test_content(differences):
     assert differences[1].source1 == 'text'
     assert differences[1].source2 == 'text'
-    expected_diff = open(data('text_ascii_expected_diff')).read()
+    expected_diff = get_data('text_ascii_expected_diff')
     assert differences[1].unified_diff == expected_diff
 
 @skip_unless_tools_exist('cbfstool')
diff --git a/tests/comparators/test_cpio.py b/tests/comparators/test_cpio.py
index 5c05200..25ec19c 100644
--- a/tests/comparators/test_cpio.py
+++ b/tests/comparators/test_cpio.py
@@ -21,7 +21,7 @@ import pytest
 
 from diffoscope.comparators.cpio import CpioFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 from utils.nonexisting import assert_non_existing
 
@@ -42,21 +42,21 @@ def differences(cpio1, cpio2):
 
 @skip_unless_tools_exist('cpio')
 def test_listing(differences):
-    expected_diff = open(data('cpio_listing_expected_diff')).read()
+    expected_diff = get_data('cpio_listing_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('cpio')
 def test_symlink(differences):
     assert differences[1].source1 == 'dir/link'
     assert differences[1].comment == 'symlink'
-    expected_diff = open(data('symlink_expected_diff')).read()
+    expected_diff = get_data('symlink_expected_diff')
     assert differences[1].unified_diff == expected_diff
 
 @skip_unless_tools_exist('cpio')
 def test_compressed_files(differences):
     assert differences[2].source1 == 'dir/text'
     assert differences[2].source2 == 'dir/text'
-    expected_diff = open(data('text_ascii_expected_diff')).read()
+    expected_diff = get_data('text_ascii_expected_diff')
     assert differences[2].unified_diff == expected_diff
 
 @skip_unless_tools_exist('cpio')
diff --git a/tests/comparators/test_deb.py b/tests/comparators/test_deb.py
index 4727d87..4487da2 100644
--- a/tests/comparators/test_deb.py
+++ b/tests/comparators/test_deb.py
@@ -27,7 +27,7 @@ from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 
 
 deb1 = load_fixture('test1.deb')
@@ -45,7 +45,7 @@ def differences(deb1, deb2):
     return deb1.compare(deb2).details
 
 def test_metadata(differences):
-    expected_diff = open(data('deb_metadata_expected_diff')).read()
+    expected_diff = get_data('deb_metadata_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 def test_compressed_files(differences):
diff --git a/tests/comparators/test_debian.py b/tests/comparators/test_debian.py
index 6d40f2d..335d07f 100644
--- a/tests/comparators/test_debian.py
+++ b/tests/comparators/test_debian.py
@@ -25,7 +25,7 @@ from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils.data import data
+from utils.data import data, get_data
 from utils.nonexisting import assert_non_existing
 
 try:
@@ -127,15 +127,15 @@ def test_dot_changes_no_differences_exclude_buildinfo(dot_changes1, dot_changes3
 @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed')
 def test_dot_changes_identical_contents_and_different_files(dot_changes_differences_identical_contents_and_different_files):
     assert dot_changes_differences_identical_contents_and_different_files[0]
-    expected_diff = open(data('dot_changes_identical_contents_and_different_files_expected_diff')).read()
+    expected_diff = get_data('dot_changes_identical_contents_and_different_files_expected_diff')
     assert dot_changes_differences_identical_contents_and_different_files[0].unified_diff == expected_diff
 
 @pytest.mark.skipif(miss_debian_module, reason='debian module is not installed')
 def test_dot_changes_different_contents_and_identical_files(dot_changes_differences_different_contents_and_identical_files):
     assert dot_changes_differences_different_contents_and_identical_files[0]
     assert dot_changes_differences_different_contents_and_identical_files[1]
-    expected_diff_contents = open(data('dot_changes_description_expected_diff')).read()
-    expected_diff_files = open(data('dot_changes_different_contents_and_identical_files_expected_diff')).read()
+    expected_diff_contents = get_data('dot_changes_description_expected_diff')
+    expected_diff_files = get_data('dot_changes_different_contents_and_identical_files_expected_diff')
     assert dot_changes_differences_different_contents_and_identical_files[0].unified_diff == expected_diff_contents
     assert dot_changes_differences_different_contents_and_identical_files[1].unified_diff == expected_diff_files
 
diff --git a/tests/comparators/test_device.py b/tests/comparators/test_device.py
index 19209ce..51363cc 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, data
+from utils.data import load_fixture, get_data
 
 text_ascii1 = load_fixture('text_ascii1')
 
@@ -43,11 +43,9 @@ def test_identification(devnull):
     assert isinstance(devnull, Device)
 
 def test_diff(differences):
-    with open(data('device_expected_diff')) as f:
-        expected_diff = f.read()
+    expected_diff = get_data('device_expected_diff')
     assert differences.unified_diff == expected_diff
 
 def test_diff_reverse(differences_reverse):
-    with open(data('device_expected_diff_reverse')) as f:
-        expected_diff = f.read()
+    expected_diff = get_data('device_expected_diff_reverse')
     assert differences_reverse.unified_diff == expected_diff
diff --git a/tests/comparators/test_dex.py b/tests/comparators/test_dex.py
index 46199c7..7668df7 100644
--- a/tests/comparators/test_dex.py
+++ b/tests/comparators/test_dex.py
@@ -24,7 +24,7 @@ from diffoscope.config import Config
 from diffoscope.comparators.dex import DexFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
 
 from test_java import javap_version
@@ -67,7 +67,7 @@ def test_differences(differences):
     assert zipinfo.source2 == 'zipinfo -v {}'
     assert classdiff.source1 == 'com/example/MainActivity.class'
     assert classdiff.source2 == 'com/example/MainActivity.class'
-    expected_diff = open(data('dex_expected_diffs')).read()
+    expected_diff = get_data('dex_expected_diffs')
     found_diff = zipinfo.unified_diff + classdiff.details[0].unified_diff
     assert expected_diff == found_diff
 
diff --git a/tests/comparators/test_directory.py b/tests/comparators/test_directory.py
index b655ef5..2210cbb 100644
--- a/tests/comparators/test_directory.py
+++ b/tests/comparators/test_directory.py
@@ -23,7 +23,7 @@ import pytest
 
 from diffoscope.comparators.directory import compare_directories
 
-from utils.data import data
+from utils.data import data, get_data
 
 
 TEST_FILE1_PATH = data('text_ascii1')
@@ -56,7 +56,7 @@ def differences(tmpdir):
 def test_content(differences):
     assert differences[0].source1 == 'dir'
     assert differences[0].details[0].source1 == 'text'
-    expected_diff = open(data('text_ascii_expected_diff')).read()
+    expected_diff = get_data('text_ascii_expected_diff')
     assert differences[0].details[0].unified_diff == expected_diff
 
 def test_stat(differences):
diff --git a/tests/comparators/test_elf.py b/tests/comparators/test_elf.py
index efd0f6c..dd62f3a 100644
--- a/tests/comparators/test_elf.py
+++ b/tests/comparators/test_elf.py
@@ -27,7 +27,7 @@ from diffoscope.comparators.directory import FilesystemDirectory
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils.data import data, load_fixture
+from utils.data import data, load_fixture, get_data
 from utils.tools import skip_unless_tools_exist, \
     skip_if_binutils_does_not_support_x86
 
@@ -64,7 +64,7 @@ def test_obj_compare_non_existing(monkeypatch, obj1):
 @skip_if_binutils_does_not_support_x86()
 def test_diff(obj_differences):
     assert len(obj_differences) == 1
-    expected_diff = open(data('elf_obj_expected_diff')).read()
+    expected_diff = get_data('elf_obj_expected_diff')
     assert obj_differences[0].unified_diff == expected_diff
 
 TEST_LIB1_PATH = data('test1.a')
@@ -94,10 +94,10 @@ def lib_differences(lib1, lib2):
 def test_lib_differences(lib_differences):
     assert len(lib_differences) == 2
     assert lib_differences[0].source1 == 'file list'
-    expected_metadata_diff = open(data('elf_lib_metadata_expected_diff')).read()
+    expected_metadata_diff = get_data('elf_lib_metadata_expected_diff')
     assert lib_differences[0].unified_diff == expected_metadata_diff
     assert 'objdump' in lib_differences[1].source1
-    expected_objdump_diff = open(data('elf_lib_objdump_expected_diff')).read()
+    expected_objdump_diff = get_data('elf_lib_objdump_expected_diff')
     assert lib_differences[1].unified_diff == expected_objdump_diff
 
 @skip_unless_tools_exist('readelf', 'objdump')
@@ -141,5 +141,5 @@ def test_differences_with_dbgsym(dbgsym_differences):
 def test_original_gnu_debuglink(dbgsym_differences):
     bin_details = dbgsym_differences.details[2].details[0].details[0]
     assert '.gnu_debuglink' in bin_details.details[2].source1
-    expected_gnu_debuglink = open(data('gnu_debuglink_expected_diff')).read()
+    expected_gnu_debuglink = get_data('gnu_debuglink_expected_diff')
     assert bin_details.details[2].unified_diff == expected_gnu_debuglink
diff --git a/tests/comparators/test_epub.py b/tests/comparators/test_epub.py
index 4d6f392..851e274 100644
--- a/tests/comparators/test_epub.py
+++ b/tests/comparators/test_epub.py
@@ -23,7 +23,7 @@ from diffoscope.config import Config
 from diffoscope.comparators.zip import ZipFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 
 
@@ -51,7 +51,7 @@ def test_differences(differences):
     assert differences[2].source2 == 'toc.ncx'
     assert differences[3].source1 == 'ch001.xhtml'
     assert differences[3].source2 == 'ch001.xhtml'
-    expected_diff = open(data('epub_expected_diffs')).read()
+    expected_diff = get_data('epub_expected_diffs')
     assert expected_diff == "".join(map(lambda x: x.unified_diff, differences))
 
 @skip_unless_tools_exist('zipinfo')
diff --git a/tests/comparators/test_fonts.py b/tests/comparators/test_fonts.py
index 864d4d4..209571f 100644
--- a/tests/comparators/test_fonts.py
+++ b/tests/comparators/test_fonts.py
@@ -23,7 +23,7 @@ from diffoscope.config import Config
 from diffoscope.comparators.fonts import TtfFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 
 
@@ -43,7 +43,7 @@ def differences(ttf1, ttf2):
 
 @skip_unless_tools_exist('showttf')
 def test_diff(differences):
-    expected_diff = open(data('ttf_expected_diff')).read()
+    expected_diff = get_data('ttf_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('showttf')
diff --git a/tests/comparators/test_fsimage.py b/tests/comparators/test_fsimage.py
index 7e2d659..a4656b8 100644
--- a/tests/comparators/test_fsimage.py
+++ b/tests/comparators/test_fsimage.py
@@ -23,7 +23,7 @@ from diffoscope.config import Config
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.fsimage import FsImageFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 
 
@@ -75,7 +75,7 @@ def test_differences(differences):
     assert tardiff.source2 == './date.txt'
     assert encodingdiff.source1 == 'encoding'
     assert encodingdiff.source2 == 'encoding'
-    expected_diff = open(data('ext4_expected_diffs'), encoding='utf-8').read()
+    expected_diff = get_data('ext4_expected_diffs')
     found_diff = tarinfo.unified_diff + tardiff.unified_diff + encodingdiff.unified_diff
     assert expected_diff == found_diff
 
diff --git a/tests/comparators/test_gettext.py b/tests/comparators/test_gettext.py
index ce81b63..d522def 100644
--- a/tests/comparators/test_gettext.py
+++ b/tests/comparators/test_gettext.py
@@ -24,7 +24,7 @@ from diffoscope.config import Config
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.gettext import MoFile
 
-from utils.data import data, load_fixture
+from utils.data import data, load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 
 
@@ -44,7 +44,7 @@ def differences(mo1, mo2):
 
 @skip_unless_tools_exist('msgunfmt')
 def test_diff(differences):
-    expected_diff = open(data('mo_expected_diff')).read()
+    expected_diff = get_data('mo_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 mo_no_charset = load_fixture('test_no_charset.mo')
diff --git a/tests/comparators/test_git.py b/tests/comparators/test_git.py
index 0e2e0a0..f075122 100644
--- a/tests/comparators/test_git.py
+++ b/tests/comparators/test_git.py
@@ -21,7 +21,7 @@ import pytest
 
 from diffoscope.comparators.git import GitIndexFile
 
-from utils.data import data, load_fixture
+from utils.data import get_data, load_fixture
 
 
 git1 = load_fixture('test1.git-index')
@@ -38,6 +38,5 @@ 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()
+    expected_diff = get_data('git_expected_diff')
     assert differences[0].unified_diff == expected_diff
diff --git a/tests/comparators/test_gzip.py b/tests/comparators/test_gzip.py
index 5d2c7c2..5a13eea 100644
--- a/tests/comparators/test_gzip.py
+++ b/tests/comparators/test_gzip.py
@@ -26,7 +26,7 @@ from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 
 
 gzip1 = load_fixture('test1.gz')
@@ -47,7 +47,7 @@ def differences(gzip1, gzip2):
 def test_metadata(differences):
     assert differences[0].source1 == 'metadata'
     assert differences[0].source2 == 'metadata'
-    expected_diff = open(data('gzip_metadata_expected_diff')).read()
+    expected_diff = get_data('gzip_metadata_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 def test_content_source(differences):
@@ -66,7 +66,7 @@ def test_content_source_without_extension(tmpdir, gzip1, gzip2):
     assert difference[1].source2 == 'test2-content'
 
 def test_content_diff(differences):
-    expected_diff = open(data('text_ascii_expected_diff')).read()
+    expected_diff = get_data('text_ascii_expected_diff')
     assert differences[1].unified_diff == expected_diff
 
 def test_compare_non_existing(monkeypatch, gzip1):
diff --git a/tests/comparators/test_haskell.py b/tests/comparators/test_haskell.py
index 829207f..08133a2 100644
--- a/tests/comparators/test_haskell.py
+++ b/tests/comparators/test_haskell.py
@@ -22,7 +22,7 @@ import pytest
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.haskell import HiFile
 
-from utils.data import data, load_fixture
+from utils.data import get_data, load_fixture
 from utils.tools import skip_unless_tools_exist
 
 
@@ -48,6 +48,5 @@ def test_diff(haskell1, differences):
     if isinstance(haskell1, FilesystemFile):
         pytest.skip("mismatch between system ghc and fixture")
 
-    with open(data('haskell_expected_diff')) as f:
-        expected_diff = f.read()
+    expected_diff = get_data('haskell_expected_diff')
     assert differences[0].unified_diff == expected_diff
diff --git a/tests/comparators/test_icc.py b/tests/comparators/test_icc.py
index b0a6020..47a26b6 100644
--- a/tests/comparators/test_icc.py
+++ b/tests/comparators/test_icc.py
@@ -23,7 +23,7 @@ from diffoscope.config import Config
 from diffoscope.comparators.icc import IccFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 
 
@@ -43,7 +43,7 @@ def differences(icc1, icc2):
 
 @skip_unless_tools_exist('cd-iccdump')
 def test_diff(differences):
-    expected_diff = open(data('icc_expected_diff')).read()
+    expected_diff = get_data('icc_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('cd-iccdump')
diff --git a/tests/comparators/test_ico_image.py b/tests/comparators/test_ico_image.py
index 9cac3a3..7543adf 100644
--- a/tests/comparators/test_ico_image.py
+++ b/tests/comparators/test_ico_image.py
@@ -21,7 +21,7 @@ import pytest
 
 from diffoscope.comparators.image import ICOImageFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
 from test_jpeg_image import identify_version
 
@@ -44,7 +44,7 @@ def differences(image1, image2):
 
 @skip_unless_tools_exist('img2txt', 'convert')
 def test_diff(differences):
-    expected_diff = open(data('ico_image_expected_diff')).read()
+    expected_diff = get_data('ico_image_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @pytest.fixture
@@ -54,5 +54,5 @@ def differences_meta(image1_meta, image2_meta):
 @skip_unless_tools_exist('img2txt', 'identify')
 @skip_unless_tool_is_at_least('identify', identify_version, '6.9.6')
 def test_diff_meta(differences_meta):
-    expected_diff = open(data('ico_image_meta_expected_diff')).read()
+    expected_diff = get_data('ico_image_meta_expected_diff')
     assert differences_meta[-1].unified_diff == expected_diff
diff --git a/tests/comparators/test_ipk.py b/tests/comparators/test_ipk.py
index 4f04603..b1d084d 100644
--- a/tests/comparators/test_ipk.py
+++ b/tests/comparators/test_ipk.py
@@ -23,7 +23,7 @@ from diffoscope.config import Config
 from diffoscope.comparators.ipk import IpkFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 
 
 ipk1 = load_fixture('base-files_157-r45695_ar71xx.ipk')
@@ -42,7 +42,7 @@ def differences(ipk1, ipk2):
 
 def test_metadata(differences):
     assert differences[0].source1 == 'metadata'
-    expected_diff = open(data('ipk_metadata_expected_diff')).read()
+    expected_diff = get_data('ipk_metadata_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 def test_compressed_files(differences):
diff --git a/tests/comparators/test_iso9660.py b/tests/comparators/test_iso9660.py
index 0147db3..e38b723 100644
--- a/tests/comparators/test_iso9660.py
+++ b/tests/comparators/test_iso9660.py
@@ -23,7 +23,7 @@ from diffoscope.config import Config
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.iso9660 import Iso9660File
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 
 
@@ -43,25 +43,25 @@ def differences(iso1, iso2):
 
 @skip_unless_tools_exist('isoinfo')
 def test_iso9660_content(differences):
-    expected_diff = open(data('iso9660_content_expected_diff')).read()
+    expected_diff = get_data('iso9660_content_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('isoinfo')
 def test_iso9660_rockridge(differences):
-    expected_diff = open(data('iso9660_rockridge_expected_diff')).read()
+    expected_diff = get_data('iso9660_rockridge_expected_diff')
     assert differences[1].unified_diff == expected_diff
 
 @skip_unless_tools_exist('isoinfo')
 def test_symlink(differences):
     assert differences[3].comment == 'symlink'
-    expected_diff = open(data('symlink_expected_diff')).read()
+    expected_diff = get_data('symlink_expected_diff')
     assert differences[3].unified_diff == expected_diff
 
 @skip_unless_tools_exist('isoinfo')
 def test_compressed_files(differences):
     assert differences[2].source1 == 'text'
     assert differences[2].source2 == 'text'
-    expected_diff = open(data('text_ascii_expected_diff')).read()
+    expected_diff = get_data('text_ascii_expected_diff')
     assert differences[2].unified_diff == expected_diff
 
 @skip_unless_tools_exist('isoinfo')
diff --git a/tests/comparators/test_java.py b/tests/comparators/test_java.py
index d1449d8..728701a 100644
--- a/tests/comparators/test_java.py
+++ b/tests/comparators/test_java.py
@@ -24,7 +24,7 @@ from diffoscope.config import Config
 from diffoscope.comparators.java import ClassFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
 
 
@@ -51,7 +51,7 @@ def differences(class1, class2):
 
 @skip_unless_tool_is_at_least('javap', javap_version, '1.8')
 def test_diff(differences):
-    expected_diff = open(data('class_expected_diff')).read()
+    expected_diff = get_data('class_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('javap')
diff --git a/tests/comparators/test_javascript.py b/tests/comparators/test_javascript.py
index 9105b86..9511098 100644
--- a/tests/comparators/test_javascript.py
+++ b/tests/comparators/test_javascript.py
@@ -23,7 +23,7 @@ from diffoscope.config import Config
 from diffoscope.comparators.javascript import JavaScriptFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 
 
@@ -43,7 +43,7 @@ def differences(javascript1, javascript2):
 
 @skip_unless_tools_exist('js-beautify')
 def test_diff(differences):
-    expected_diff = open(data('javascript_expected_diff')).read()
+    expected_diff = get_data('javascript_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('js-beautify')
diff --git a/tests/comparators/test_jpeg_image.py b/tests/comparators/test_jpeg_image.py
index 42552ff..70012b4 100644
--- a/tests/comparators/test_jpeg_image.py
+++ b/tests/comparators/test_jpeg_image.py
@@ -24,7 +24,7 @@ from diffoscope.config import Config
 from diffoscope.comparators.image import JPEGImageFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
 
 
@@ -52,7 +52,7 @@ def differences(image1, image2):
 
 @skip_unless_tools_exist('img2txt', 'identify')
 def test_diff(differences):
-    expected_diff = open(data('jpeg_image_expected_diff')).read()
+    expected_diff = get_data('jpeg_image_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('img2txt', 'identify')
@@ -69,5 +69,5 @@ def differences_meta(image1_meta, image2_meta):
 @skip_unless_tools_exist('img2txt', 'identify')
 @skip_unless_tool_is_at_least('identify', identify_version, '6.9.6')
 def test_diff_meta(differences_meta):
-    expected_diff = open(data('jpeg_image_meta_expected_diff')).read()
+    expected_diff = get_data('jpeg_image_meta_expected_diff')
     assert differences_meta[-1].unified_diff == expected_diff
diff --git a/tests/comparators/test_json.py b/tests/comparators/test_json.py
index 67c8b2c..67343cb 100644
--- a/tests/comparators/test_json.py
+++ b/tests/comparators/test_json.py
@@ -21,7 +21,7 @@ import pytest
 
 from diffoscope.comparators.json import JSONFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.nonexisting import assert_non_existing
 
 
@@ -41,8 +41,8 @@ def differences(json1, json2):
     return json1.compare(json2).details
 
 def test_diff(differences):
-    with open(data('json_expected_diff')) as f:
-        expected_diff = f.read()
+    expected_diff = get_data('json_expected_diff')
+
     assert differences[0].unified_diff == expected_diff
 
 def test_compare_non_existing(monkeypatch, json1):
@@ -51,4 +51,4 @@ def test_compare_non_existing(monkeypatch, json1):
 def test_ordering_differences(json3a, json3b):
     diff = json3a.compare(json3b)
     assert diff.details[0]._comments == ['ordering differences only']
-    assert diff.details[0].unified_diff == open(data('order1.diff')).read()
+    assert diff.details[0].unified_diff == get_data('order1.diff')
diff --git a/tests/comparators/test_macho.py b/tests/comparators/test_macho.py
index d061bce..49982bf 100644
--- a/tests/comparators/test_macho.py
+++ b/tests/comparators/test_macho.py
@@ -25,7 +25,7 @@ from diffoscope.config import Config
 from diffoscope.comparators.macho import MachoFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 
 
@@ -57,5 +57,5 @@ def test_diff(obj_differences):
     for idx, diff in enumerate(obj_differences):
         with open(os.path.join(os.path.dirname(__file__), '../data', l[idx]), 'w') as f:
             print(diff.unified_diff, file=f)
-    expected_diff = open(data('macho_expected_diff')).read()
+    expected_diff = get_data('macho_expected_diff')
     assert obj_differences[0].unified_diff == expected_diff
diff --git a/tests/comparators/test_mono.py b/tests/comparators/test_mono.py
index d7bc4d1..7ec7e57 100644
--- a/tests/comparators/test_mono.py
+++ b/tests/comparators/test_mono.py
@@ -23,7 +23,7 @@ from diffoscope.config import Config
 from diffoscope.comparators.mono import MonoExeFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 
 
@@ -48,7 +48,7 @@ def differences(exe1, exe2):
 
 @skip_unless_tools_exist('pedump')
 def test_diff(differences):
-    expected_diff = open(data('pe_expected_diff')).read()
+    expected_diff = get_data('pe_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('pedump')
diff --git a/tests/comparators/test_openssh_pub_key.py b/tests/comparators/test_openssh_pub_key.py
index bdb9280..3b8ce14 100644
--- a/tests/comparators/test_openssh_pub_key.py
+++ b/tests/comparators/test_openssh_pub_key.py
@@ -24,7 +24,7 @@ from diffoscope.config import Config
 from diffoscope.comparators.openssh import PublicKeyFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
 
 
@@ -52,7 +52,7 @@ def differences(opensshpubkey1, opensshpubkey2):
 
 @skip_unless_tool_is_at_least('ssh-keygen', openssh_version, '6.9')
 def test_diff(differences):
-    expected_diff = open(data('openssh_pub_key_expected_diff')).read()
+    expected_diff = get_data('openssh_pub_key_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('ssh-keygen')
diff --git a/tests/comparators/test_pdf.py b/tests/comparators/test_pdf.py
index 5b05f4f..71bd38d 100644
--- a/tests/comparators/test_pdf.py
+++ b/tests/comparators/test_pdf.py
@@ -21,7 +21,7 @@ import pytest
 
 from diffoscope.comparators.pdf import PdfFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 from utils.nonexisting import assert_non_existing
 
@@ -42,12 +42,12 @@ def differences(pdf1, pdf2):
 
 @skip_unless_tools_exist('pdftk', 'pdftotext')
 def test_text_diff(differences):
-    expected_diff = open(data('pdf_text_expected_diff')).read()
+    expected_diff = get_data('pdf_text_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('pdftk', 'pdftotext')
 def test_internal_diff(differences):
-    expected_diff = open(data('pdf_internal_expected_diff')).read()
+    expected_diff = get_data('pdf_internal_expected_diff')
     assert differences[1].unified_diff == expected_diff
 
 @skip_unless_tools_exist('pdftk', 'pdftotext')
diff --git a/tests/comparators/test_png.py b/tests/comparators/test_png.py
index f5a86e2..8e8ee45 100644
--- a/tests/comparators/test_png.py
+++ b/tests/comparators/test_png.py
@@ -21,7 +21,7 @@ import pytest
 
 from diffoscope.comparators.png import PngFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 from utils.nonexisting import assert_non_existing
 
@@ -42,7 +42,7 @@ def differences(png1, png2):
 
 @skip_unless_tools_exist('sng')
 def test_diff(differences):
-    expected_diff = open(data('png_expected_diff')).read()
+    expected_diff = get_data('png_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('sng')
diff --git a/tests/comparators/test_ppu.py b/tests/comparators/test_ppu.py
index ce4970a..83d4fa5 100644
--- a/tests/comparators/test_ppu.py
+++ b/tests/comparators/test_ppu.py
@@ -23,7 +23,7 @@ import subprocess
 
 from diffoscope.comparators.ppu import PpuFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
 from utils.nonexisting import assert_non_existing
 
@@ -58,7 +58,7 @@ def differences(file1, file2):
 @skip_unless_tool_is_at_least('ppudump', ppudump_version, '3.0.0')
 def test_diff(differences):
     print(differences[0].unified_diff)
-    expected_diff = open(data('ppu_expected_diff')).read()
+    expected_diff = get_data('ppu_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tool_is_at_least('ppudump', ppudump_version, '3.0.0')
diff --git a/tests/comparators/test_ps.py b/tests/comparators/test_ps.py
index dc77145..151ddf9 100644
--- a/tests/comparators/test_ps.py
+++ b/tests/comparators/test_ps.py
@@ -21,7 +21,7 @@ import pytest
 
 from diffoscope.comparators.ps import PsFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 from utils.nonexisting import assert_non_existing
 
@@ -42,12 +42,12 @@ def differences(ps1, ps2):
 
 @skip_unless_tools_exist('ps2ascii')
 def test_internal_diff(differences):
-    expected_diff = open(data('ps_internal_expected_diff')).read()
+    expected_diff = get_data('ps_internal_expected_diff')
     assert differences.unified_diff == expected_diff
 
 @skip_unless_tools_exist('ps2ascii')
 def test_text_diff(differences):
-    expected_diff = open(data('ps_text_expected_diff')).read()
+    expected_diff = get_data('ps_text_expected_diff')
     assert differences.details[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('ps2ascii')
diff --git a/tests/comparators/test_rlib.py b/tests/comparators/test_rlib.py
index ab7a090..5b54f52 100644
--- a/tests/comparators/test_rlib.py
+++ b/tests/comparators/test_rlib.py
@@ -24,7 +24,7 @@ import subprocess
 from diffoscope.comparators.ar import ArFile
 
 from utils import diff_ignore_line_numbers
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least, \
     skip_if_binutils_does_not_support_x86
 from utils.nonexisting import assert_non_existing
@@ -57,7 +57,7 @@ def test_num_items(differences):
 def test_item0_armap(differences):
     assert differences[0].source1 == 'nm -s {}'
     assert differences[0].source2 == 'nm -s {}'
-    expected_diff = open(data('rlib_armap_expected_diff')).read()
+    expected_diff = get_data('rlib_armap_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('nm')
@@ -65,7 +65,7 @@ def test_item0_armap(differences):
 def test_item1_elf(differences):
     assert differences[1].source1 == 'alloc_system-d16b8f0e.0.o'
     assert differences[1].source2 == 'alloc_system-d16b8f0e.0.o'
-    expected_diff = open(data('rlib_elf_expected_diff')).read()
+    expected_diff = get_data('rlib_elf_expected_diff')
     assert differences[1].details[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('nm')
@@ -78,7 +78,7 @@ def test_item2_rust_metadata_bin(differences):
 def test_item3_deflate_llvm_bitcode(differences):
     assert differences[3].source1 == 'alloc_system-d16b8f0e.0.bytecode.deflate'
     assert differences[3].source2 == 'alloc_system-d16b8f0e.0.bytecode.deflate'
-    expected_diff = open(data('rlib_llvm_dis_expected_diff')).read()
+    expected_diff = get_data('rlib_llvm_dis_expected_diff')
     actual_diff = differences[3].details[0].details[1].unified_diff
     assert diff_ignore_line_numbers(actual_diff) == diff_ignore_line_numbers(expected_diff)
 
diff --git a/tests/comparators/test_rpm.py b/tests/comparators/test_rpm.py
index 644d3e2..62b3072 100644
--- a/tests/comparators/test_rpm.py
+++ b/tests/comparators/test_rpm.py
@@ -19,7 +19,7 @@
 
 import pytest
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 from utils.nonexisting import assert_non_existing
 
@@ -50,7 +50,7 @@ def differences(rpm1, rpm2):
 @skip_unless_tools_exist('rpm2cpio')
 def test_header(differences):
     assert differences[0].source1 == 'header'
-    expected_diff = open(data('rpm_header_expected_diff')).read()
+    expected_diff = get_data('rpm_header_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @pytest.mark.skipif(miss_rpm_module, reason='rpm module is not installed')
@@ -58,7 +58,7 @@ def test_header(differences):
 def test_listing(differences):
     assert differences[1].source1 == 'content'
     assert differences[1].details[0].source1 == 'file list'
-    expected_diff = open(data('rpm_listing_expected_diff')).read()
+    expected_diff = get_data('rpm_listing_expected_diff')
     assert differences[1].details[0].unified_diff == expected_diff
 
 @pytest.mark.skipif(miss_rpm_module, reason='rpm module is not installed')
@@ -66,7 +66,7 @@ def test_listing(differences):
 def test_content(differences):
     assert differences[1].source1 == 'content'
     assert differences[1].details[1].source1 == './dir/text'
-    expected_diff = open(data('text_ascii_expected_diff')).read()
+    expected_diff = get_data('text_ascii_expected_diff')
     assert differences[1].details[1].unified_diff == expected_diff
 
 @pytest.mark.skipif(miss_rpm_module, reason='rpm module is not installed')
diff --git a/tests/comparators/test_sqlite.py b/tests/comparators/test_sqlite.py
index 29562e8..e5ba5e4 100644
--- a/tests/comparators/test_sqlite.py
+++ b/tests/comparators/test_sqlite.py
@@ -21,7 +21,7 @@ import pytest
 
 from diffoscope.comparators.sqlite import Sqlite3Database
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 from utils.nonexisting import assert_non_existing
 
@@ -42,7 +42,7 @@ def differences(sqlite3db1, sqlite3db2):
 
 @skip_unless_tools_exist('sqlite3')
 def test_diff(differences):
-    expected_diff = open(data('sqlite3_expected_diff')).read()
+    expected_diff = get_data('sqlite3_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('sqlite3')
diff --git a/tests/comparators/test_squashfs.py b/tests/comparators/test_squashfs.py
index 25c32f5..1b379ef 100644
--- a/tests/comparators/test_squashfs.py
+++ b/tests/comparators/test_squashfs.py
@@ -22,7 +22,7 @@ import subprocess
 
 from diffoscope.comparators.squashfs import SquashfsFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
 from utils.nonexisting import assert_non_existing
 
@@ -57,20 +57,20 @@ def differences(squashfs1, squashfs2):
 
 @skip_unless_tool_is_at_least('unsquashfs', unsquashfs_version, '4.3')
 def test_superblock(differences):
-    expected_diff = open(data('squashfs_superblock_expected_diff')).read()
+    expected_diff = get_data('squashfs_superblock_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('unsquashfs')
 def test_symlink(differences):
     assert differences[2].comment == 'symlink'
-    expected_diff = open(data('symlink_expected_diff')).read()
+    expected_diff = get_data('symlink_expected_diff')
     assert differences[2].unified_diff == expected_diff
 
 @skip_unless_tools_exist('unsquashfs')
 def test_compressed_files(differences):
     assert differences[3].source1 == '/text'
     assert differences[3].source2 == '/text'
-    expected_diff = open(data('text_ascii_expected_diff')).read()
+    expected_diff = get_data('text_ascii_expected_diff')
     assert differences[3].unified_diff == expected_diff
 
 @skip_unless_tools_exist('unsquashfs')
diff --git a/tests/comparators/test_symlink.py b/tests/comparators/test_symlink.py
index d470b79..5c218fe 100644
--- a/tests/comparators/test_symlink.py
+++ b/tests/comparators/test_symlink.py
@@ -22,7 +22,7 @@ import os
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils.data import data
+from utils.data import get_data
 
 
 def test_destination(tmpdir):
@@ -34,6 +34,6 @@ def test_destination(tmpdir):
     a = create('a')
     b = create('b')
 
-    expected_diff = open(data('symlink_expected_destination_diff')).read()
+    expected_diff = get_data('symlink_expected_destination_diff')
 
     assert a.compare(b).unified_diff == expected_diff
diff --git a/tests/comparators/test_tar.py b/tests/comparators/test_tar.py
index 88bc408..467cf14 100644
--- a/tests/comparators/test_tar.py
+++ b/tests/comparators/test_tar.py
@@ -23,7 +23,7 @@ from diffoscope.config import Config
 from diffoscope.comparators.tar import TarFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.nonexisting import assert_non_existing
 
 
@@ -42,20 +42,20 @@ def differences(tar1, tar2):
     return tar1.compare(tar2).details
 
 def test_listing(differences):
-    expected_diff = open(data('tar_listing_expected_diff')).read()
+    expected_diff = get_data('tar_listing_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 def test_symlinks(differences):
     assert differences[2].source1 == 'dir/link'
     assert differences[2].source2 == 'dir/link'
     assert differences[2].comment == 'symlink'
-    expected_diff = open(data('symlink_expected_diff')).read()
+    expected_diff = get_data('symlink_expected_diff')
     assert differences[2].unified_diff == expected_diff
 
 def test_text_file(differences):
     assert differences[1].source1 == 'dir/text'
     assert differences[1].source2 == 'dir/text'
-    expected_diff = open(data('text_ascii_expected_diff')).read()
+    expected_diff = get_data('text_ascii_expected_diff')
     assert differences[1].unified_diff == expected_diff
 
 def test_compare_non_existing(monkeypatch, tar1):
diff --git a/tests/comparators/test_text.py b/tests/comparators/test_text.py
index e109945..cf21d21 100644
--- a/tests/comparators/test_text.py
+++ b/tests/comparators/test_text.py
@@ -22,7 +22,7 @@ import codecs
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils.data import data, load_fixture
+from utils.data import data, load_fixture, get_data
 from utils.nonexisting import assert_non_existing
 
 
@@ -36,7 +36,7 @@ def test_no_differences(ascii1):
 def test_difference_in_ascii(ascii1, ascii2):
     difference = ascii1.compare(ascii2)
     assert difference is not None
-    expected_diff = open(data('text_ascii_expected_diff')).read()
+    expected_diff = get_data('text_ascii_expected_diff')
     assert difference.unified_diff == expected_diff
     assert not difference.comments
     assert len(difference.details) == 0
@@ -74,4 +74,4 @@ text_order2 = load_fixture('text_order2')
 def test_ordering_differences(text_order1, text_order2):
     difference = text_order1.compare(text_order2)
     assert difference.comments == ['ordering differences only']
-    assert difference.unified_diff == open(data('text_order_expected_diff')).read()
+    assert difference.unified_diff == get_data('text_order_expected_diff')
diff --git a/tests/comparators/test_xz.py b/tests/comparators/test_xz.py
index 40de745..2860258 100644
--- a/tests/comparators/test_xz.py
+++ b/tests/comparators/test_xz.py
@@ -24,7 +24,7 @@ from diffoscope.comparators.xz import XzFile
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 from utils.nonexisting import assert_non_existing
 
@@ -61,7 +61,7 @@ def test_content_source_without_extension(tmpdir, xz1, xz2):
 
 @skip_unless_tools_exist('xz')
 def test_content_diff(differences):
-    expected_diff = open(data('text_ascii_expected_diff')).read()
+    expected_diff = get_data('text_ascii_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('xz')
diff --git a/tests/comparators/test_zip.py b/tests/comparators/test_zip.py
index c66afa2..b98619f 100644
--- a/tests/comparators/test_zip.py
+++ b/tests/comparators/test_zip.py
@@ -21,7 +21,7 @@ import pytest
 
 from diffoscope.comparators.zip import ZipFile, MozillaZipFile
 
-from utils.data import data, load_fixture
+from utils.data import load_fixture, get_data
 from utils.tools import skip_unless_tools_exist
 from utils.nonexisting import assert_non_existing
 
@@ -45,14 +45,14 @@ def differences(zip1, zip2):
 
 @skip_unless_tools_exist('zipinfo')
 def test_metadata(differences):
-    expected_diff = open(data('zip_zipinfo_expected_diff')).read()
+    expected_diff = get_data('zip_zipinfo_expected_diff')
     assert differences[0].unified_diff == expected_diff
 
 @skip_unless_tools_exist('zipinfo')
 def test_compressed_files(differences):
     assert differences[1].source1 == 'dir/text'
     assert differences[1].source2 == 'dir/text'
-    expected_diff = open(data('text_ascii_expected_diff')).read()
+    expected_diff = get_data('text_ascii_expected_diff')
     assert differences[1].unified_diff == expected_diff
 
 @skip_unless_tools_exist('zipinfo')
@@ -72,7 +72,7 @@ def mozzip_differences(mozzip1, mozzip2):
 
 @skip_unless_tools_exist('zipinfo')
 def test_mozzip_metadata(mozzip_differences, mozzip1, mozzip2):
-    expected_diff = open(data('mozzip_zipinfo_expected_diff')).read()
+    expected_diff = get_data('mozzip_zipinfo_expected_diff')
     diff = mozzip_differences[0].unified_diff
     assert (diff.replace(mozzip1.path, 'test1.mozzip')
                 .replace(mozzip2.path, 'test2.mozzip')) == expected_diff
@@ -81,7 +81,7 @@ def test_mozzip_metadata(mozzip_differences, mozzip1, mozzip2):
 def test_mozzip_compressed_files(mozzip_differences):
     assert mozzip_differences[1].source1 == 'dir/text'
     assert mozzip_differences[1].source2 == 'dir/text'
-    expected_diff = open(data('text_ascii_expected_diff')).read()
+    expected_diff = get_data('text_ascii_expected_diff')
     assert mozzip_differences[1].unified_diff == expected_diff
 
 @skip_unless_tools_exist('zipinfo')

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



More information about the Reproducible-commits mailing list