[diffoscope] 01/02: Refactor: move tests/comparators/utils up one directory

Ximin Luo infinity0 at debian.org
Mon May 29 22:24:28 CEST 2017


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

infinity0 pushed a commit to branch experimental
in repository diffoscope.

commit 761323b7a0666d1c689cc1ffac37b8f7ad4f3071
Author: Ximin Luo <infinity0 at debian.org>
Date:   Mon May 29 22:19:58 2017 +0200

    Refactor: move tests/comparators/utils up one directory
---
 .../comparators/utils => tests}/__init__.py        |  0
 .../utils => tests/comparators}/__init__.py        |  0
 tests/comparators/test_apk.py                      |  6 +--
 tests/comparators/test_archive.py                  |  2 +-
 tests/comparators/test_binary.py                   |  4 +-
 tests/comparators/test_bzip2.py                    |  6 +--
 tests/comparators/test_cbfs.py                     |  6 +--
 tests/comparators/test_cpio.py                     |  6 +--
 tests/comparators/test_deb.py                      |  2 +-
 tests/comparators/test_debian.py                   |  6 +--
 tests/comparators/test_device.py                   |  4 +-
 tests/comparators/test_dex.py                      |  6 +--
 tests/comparators/test_directory.py                |  2 +-
 tests/comparators/test_docx.py                     |  6 +--
 tests/comparators/test_dtb.py                      |  4 +-
 tests/comparators/test_elf.py                      |  4 +-
 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_gif.py                      |  6 +--
 tests/comparators/test_git.py                      |  2 +-
 tests/comparators/test_gzip.py                     |  2 +-
 tests/comparators/test_haskell.py                  |  4 +-
 tests/comparators/test_icc.py                      |  4 +-
 tests/comparators/test_ico_image.py                |  6 +--
 tests/comparators/test_ipk.py                      |  2 +-
 tests/comparators/test_iso9660.py                  |  4 +-
 tests/comparators/test_java.py                     |  4 +-
 tests/comparators/test_javascript.py               |  4 +-
 tests/comparators/test_jpeg_image.py               |  4 +-
 tests/comparators/test_json.py                     |  4 +-
 tests/comparators/test_macho.py                    |  4 +-
 tests/comparators/test_mono.py                     |  4 +-
 tests/comparators/test_odt.py                      |  6 +--
 tests/comparators/test_ogg.py                      |  6 +--
 tests/comparators/test_openssh_pub_key.py          |  4 +-
 tests/comparators/test_pcap.py                     |  6 +--
 tests/comparators/test_pdf.py                      |  6 +--
 tests/comparators/test_pgp.py                      |  6 +--
 tests/comparators/test_png.py                      |  6 +--
 tests/comparators/test_ppu.py                      |  6 +--
 tests/comparators/test_ps.py                       |  6 +--
 tests/comparators/test_rdata.py                    |  8 ++--
 tests/comparators/test_rlib.py                     |  8 ++--
 tests/comparators/test_rpm.py                      |  6 +--
 tests/comparators/test_sqlite.py                   |  6 +--
 tests/comparators/test_squashfs.py                 |  6 +--
 tests/comparators/test_symlink.py                  |  2 +-
 tests/comparators/test_tar.py                      |  4 +-
 tests/comparators/test_text.py                     |  4 +-
 tests/comparators/test_utils.py                    |  4 +-
 tests/comparators/test_xz.py                       |  6 +--
 tests/comparators/test_zip.py                      |  6 +--
 tests/test_presenters.py                           | 52 +++++++---------------
 tests/test_progress.py                             |  2 +-
 tests/test_quines.py                               |  2 +-
 tests/test_readers.py                              |  2 +-
 tests/{comparators => }/utils/__init__.py          |  0
 tests/{comparators => }/utils/data.py              |  1 -
 tests/{comparators => }/utils/nonexisting.py       |  0
 tests/{comparators => }/utils/tools.py             |  0
 62 files changed, 143 insertions(+), 162 deletions(-)

diff --git a/diffoscope/comparators/utils/__init__.py b/tests/__init__.py
similarity index 100%
copy from diffoscope/comparators/utils/__init__.py
copy to tests/__init__.py
diff --git a/diffoscope/comparators/utils/__init__.py b/tests/comparators/__init__.py
similarity index 100%
copy from diffoscope/comparators/utils/__init__.py
copy to tests/comparators/__init__.py
diff --git a/tests/comparators/test_apk.py b/tests/comparators/test_apk.py
index a05dc65..0ff411a 100644
--- a/tests/comparators/test_apk.py
+++ b/tests/comparators/test_apk.py
@@ -21,9 +21,9 @@ import pytest
 
 from diffoscope.comparators.apk import ApkFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
-from utils.nonexisting import assert_non_existing
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
+from ..utils.nonexisting import assert_non_existing
 
 apk1 = load_fixture('test1.apk')
 apk2 = load_fixture('test2.apk')
diff --git a/tests/comparators/test_archive.py b/tests/comparators/test_archive.py
index 89d3eb3..17b68e0 100644
--- a/tests/comparators/test_archive.py
+++ b/tests/comparators/test_archive.py
@@ -19,7 +19,7 @@
 
 import pytest
 
-from utils.data import load_fixture
+from ..utils.data import load_fixture
 
 
 archive1 = load_fixture('archive1.tar')
diff --git a/tests/comparators/test_binary.py b/tests/comparators/test_binary.py
index bca69d4..865bbc2 100644
--- a/tests/comparators/test_binary.py
+++ b/tests/comparators/test_binary.py
@@ -32,8 +32,8 @@ 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, get_data, normalize_zeros
-from utils.tools import skip_unless_tools_exist
+from ..utils.data import data, init_fixture, get_data, normalize_zeros
+from ..utils.tools import skip_unless_tools_exist
 
 
 TEST_FILE1_PATH = data('binary1')
diff --git a/tests/comparators/test_bzip2.py b/tests/comparators/test_bzip2.py
index ce60b86..01bf799 100644
--- a/tests/comparators/test_bzip2.py
+++ b/tests/comparators/test_bzip2.py
@@ -24,9 +24,9 @@ from diffoscope.comparators.bzip2 import Bzip2File
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
-from utils.nonexisting import assert_non_existing
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
+from ..utils.nonexisting import assert_non_existing
 
 
 bzip1 = load_fixture('test1.bz2')
diff --git a/tests/comparators/test_cbfs.py b/tests/comparators/test_cbfs.py
index 33f045b..cb7f2ac 100644
--- a/tests/comparators/test_cbfs.py
+++ b/tests/comparators/test_cbfs.py
@@ -25,9 +25,9 @@ from diffoscope.comparators.cbfs import CbfsFile
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils.data import data, get_data
-from utils.tools import skip_unless_tools_exist
-from utils.nonexisting import assert_non_existing
+from ..utils.data import data, get_data
+from ..utils.tools import skip_unless_tools_exist
+from ..utils.nonexisting import assert_non_existing
 
 
 TEST_FILE1_PATH = data('text_ascii1')
diff --git a/tests/comparators/test_cpio.py b/tests/comparators/test_cpio.py
index 25ec19c..03c15c0 100644
--- a/tests/comparators/test_cpio.py
+++ b/tests/comparators/test_cpio.py
@@ -21,9 +21,9 @@ import pytest
 
 from diffoscope.comparators.cpio import CpioFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
-from utils.nonexisting import assert_non_existing
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
+from ..utils.nonexisting import assert_non_existing
 
 
 cpio1 = load_fixture('test1.cpio')
diff --git a/tests/comparators/test_deb.py b/tests/comparators/test_deb.py
index 5056f0e..90a8bb4 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 load_fixture, get_data
+from ..utils.data import load_fixture, get_data
 
 
 deb1 = load_fixture('test1.deb')
diff --git a/tests/comparators/test_debian.py b/tests/comparators/test_debian.py
index a516bbf..b9ac886 100644
--- a/tests/comparators/test_debian.py
+++ b/tests/comparators/test_debian.py
@@ -26,10 +26,10 @@ 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, get_data
-from utils.tools import skip_unless_module_exists
+from ..utils.data import data, get_data
+from ..utils.tools import skip_unless_module_exists
 
-from utils.nonexisting import assert_non_existing
+from ..utils.nonexisting import assert_non_existing
 
 try:
     from diffoscope.comparators.debian import DotChangesFile, DotDscFile, \
diff --git a/tests/comparators/test_device.py b/tests/comparators/test_device.py
index 9866e40..dcaa53a 100644
--- a/tests/comparators/test_device.py
+++ b/tests/comparators/test_device.py
@@ -23,8 +23,8 @@ 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, normalize_zeros
-from utils.tools import skip_unless_tools_exist
+from ..utils.data import load_fixture, get_data, normalize_zeros
+from ..utils.tools import skip_unless_tools_exist
 
 
 text_ascii1 = load_fixture('text_ascii1')
diff --git a/tests/comparators/test_dex.py b/tests/comparators/test_dex.py
index 7668df7..549703a 100644
--- a/tests/comparators/test_dex.py
+++ b/tests/comparators/test_dex.py
@@ -24,10 +24,10 @@ from diffoscope.config import Config
 from diffoscope.comparators.dex import DexFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
+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
+from .test_java import javap_version
 
 
 dex1 = load_fixture('test1.dex')
diff --git a/tests/comparators/test_directory.py b/tests/comparators/test_directory.py
index d4c1764..2c7c820 100644
--- a/tests/comparators/test_directory.py
+++ b/tests/comparators/test_directory.py
@@ -26,7 +26,7 @@ from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.directory import compare_directories
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils.data import data, get_data
+from ..utils.data import data, get_data
 
 
 TEST_FILE1_PATH = data('text_ascii1')
diff --git a/tests/comparators/test_docx.py b/tests/comparators/test_docx.py
index 675374c..567b189 100644
--- a/tests/comparators/test_docx.py
+++ b/tests/comparators/test_docx.py
@@ -21,9 +21,9 @@ import pytest
 
 from diffoscope.comparators.docx import DocxFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
-from utils.nonexisting import assert_non_existing
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
+from ..utils.nonexisting import assert_non_existing
 
 docx1 = load_fixture('test1.docx')
 docx2 = load_fixture('test2.docx')
diff --git a/tests/comparators/test_dtb.py b/tests/comparators/test_dtb.py
index f23e24b..6ebb4d6 100644
--- a/tests/comparators/test_dtb.py
+++ b/tests/comparators/test_dtb.py
@@ -25,8 +25,8 @@ from diffoscope.config import Config
 from diffoscope.comparators.dtb import DeviceTreeFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
 
 # Generated by: dtc --in-format=dts --out-format=dtb --out=devicetree1.dtb devicetree1.dts
 dtb1 = load_fixture('devicetree1.dtb')
diff --git a/tests/comparators/test_elf.py b/tests/comparators/test_elf.py
index a75d04e..46f1635 100644
--- a/tests/comparators/test_elf.py
+++ b/tests/comparators/test_elf.py
@@ -27,8 +27,8 @@ 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, get_data
-from utils.tools import skip_unless_tools_exist, \
+from ..utils.data import data, load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist, \
     skip_if_binutils_does_not_support_x86, skip_unless_module_exists
 
 obj1 = load_fixture('test1.o')
diff --git a/tests/comparators/test_epub.py b/tests/comparators/test_epub.py
index 851e274..2fbe5fa 100644
--- a/tests/comparators/test_epub.py
+++ b/tests/comparators/test_epub.py
@@ -23,8 +23,8 @@ from diffoscope.config import Config
 from diffoscope.comparators.zip import ZipFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
 
 
 epub1 = load_fixture('test1.epub')
diff --git a/tests/comparators/test_fonts.py b/tests/comparators/test_fonts.py
index 209571f..6951e5b 100644
--- a/tests/comparators/test_fonts.py
+++ b/tests/comparators/test_fonts.py
@@ -23,8 +23,8 @@ from diffoscope.config import Config
 from diffoscope.comparators.fonts import TtfFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
 
 
 ttf1 = load_fixture('Samyak-Malayalam1.ttf')
diff --git a/tests/comparators/test_fsimage.py b/tests/comparators/test_fsimage.py
index 104300e..5003d6d 100644
--- a/tests/comparators/test_fsimage.py
+++ b/tests/comparators/test_fsimage.py
@@ -23,8 +23,8 @@ from diffoscope.config import Config
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.fsimage import FsImageFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist, skip_unless_module_exists
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist, skip_unless_module_exists
 
 img1 = load_fixture('test1.ext4')
 img2 = load_fixture('test2.ext4')
diff --git a/tests/comparators/test_gettext.py b/tests/comparators/test_gettext.py
index d522def..96dc815 100644
--- a/tests/comparators/test_gettext.py
+++ b/tests/comparators/test_gettext.py
@@ -24,8 +24,8 @@ 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, get_data
-from utils.tools import skip_unless_tools_exist
+from ..utils.data import data, load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
 
 
 mo1 = load_fixture('test1.mo')
diff --git a/tests/comparators/test_gif.py b/tests/comparators/test_gif.py
index f714f64..9755100 100644
--- a/tests/comparators/test_gif.py
+++ b/tests/comparators/test_gif.py
@@ -22,9 +22,9 @@ import pytest
 from diffoscope.comparators.gif import GifFile
 from diffoscope.config import Config
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
-from utils.nonexisting import assert_non_existing
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
+from ..utils.nonexisting import assert_non_existing
 
 gif1 = load_fixture('test1.gif')
 gif2 = load_fixture('test2.gif')
diff --git a/tests/comparators/test_git.py b/tests/comparators/test_git.py
index f075122..c2b1247 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 get_data, load_fixture
+from ..utils.data import get_data, load_fixture
 
 
 git1 = load_fixture('test1.git-index')
diff --git a/tests/comparators/test_gzip.py b/tests/comparators/test_gzip.py
index 5a13eea..06d44af 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 load_fixture, get_data
+from ..utils.data import load_fixture, get_data
 
 
 gzip1 = load_fixture('test1.gz')
diff --git a/tests/comparators/test_haskell.py b/tests/comparators/test_haskell.py
index 08133a2..dd5bda9 100644
--- a/tests/comparators/test_haskell.py
+++ b/tests/comparators/test_haskell.py
@@ -22,8 +22,8 @@ import pytest
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.haskell import HiFile
 
-from utils.data import get_data, load_fixture
-from utils.tools import skip_unless_tools_exist
+from ..utils.data import get_data, load_fixture
+from ..utils.tools import skip_unless_tools_exist
 
 
 haskell1 = load_fixture('test1.hi')
diff --git a/tests/comparators/test_icc.py b/tests/comparators/test_icc.py
index a922965..9dede79 100644
--- a/tests/comparators/test_icc.py
+++ b/tests/comparators/test_icc.py
@@ -23,8 +23,8 @@ from diffoscope.config import Config
 from diffoscope.comparators.icc import IccFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
 
 
 icc1 = load_fixture('test1.icc')
diff --git a/tests/comparators/test_ico_image.py b/tests/comparators/test_ico_image.py
index dbea9e3..b026d3e 100644
--- a/tests/comparators/test_ico_image.py
+++ b/tests/comparators/test_ico_image.py
@@ -22,9 +22,9 @@ import pytest
 from diffoscope.comparators.image import ICOImageFile
 from diffoscope.config import Config
 
-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
+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
 
 
 image1 = load_fixture('test1.ico')
diff --git a/tests/comparators/test_ipk.py b/tests/comparators/test_ipk.py
index b1d084d..c96eb2a 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 load_fixture, get_data
+from ..utils.data import load_fixture, get_data
 
 
 ipk1 = load_fixture('base-files_157-r45695_ar71xx.ipk')
diff --git a/tests/comparators/test_iso9660.py b/tests/comparators/test_iso9660.py
index e38b723..e8d6535 100644
--- a/tests/comparators/test_iso9660.py
+++ b/tests/comparators/test_iso9660.py
@@ -23,8 +23,8 @@ from diffoscope.config import Config
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.iso9660 import Iso9660File
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
 
 
 iso1 = load_fixture('test1.iso')
diff --git a/tests/comparators/test_java.py b/tests/comparators/test_java.py
index 728701a..f4b35ea 100644
--- a/tests/comparators/test_java.py
+++ b/tests/comparators/test_java.py
@@ -24,8 +24,8 @@ from diffoscope.config import Config
 from diffoscope.comparators.java import ClassFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
 
 
 class1 = load_fixture('Test1.class')
diff --git a/tests/comparators/test_javascript.py b/tests/comparators/test_javascript.py
index 9511098..ba0cd5f 100644
--- a/tests/comparators/test_javascript.py
+++ b/tests/comparators/test_javascript.py
@@ -23,8 +23,8 @@ from diffoscope.config import Config
 from diffoscope.comparators.javascript import JavaScriptFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
 
 
 javascript1 = load_fixture('test1.js')
diff --git a/tests/comparators/test_jpeg_image.py b/tests/comparators/test_jpeg_image.py
index 78735db..89ac42f 100644
--- a/tests/comparators/test_jpeg_image.py
+++ b/tests/comparators/test_jpeg_image.py
@@ -24,8 +24,8 @@ from diffoscope.config import Config
 from diffoscope.comparators.image import JPEGImageFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
 
 
 image1 = load_fixture('test1.jpg')
diff --git a/tests/comparators/test_json.py b/tests/comparators/test_json.py
index 379e0a1..f10da08 100644
--- a/tests/comparators/test_json.py
+++ b/tests/comparators/test_json.py
@@ -21,8 +21,8 @@ import pytest
 
 from diffoscope.comparators.json import JSONFile
 
-from utils.data import load_fixture, get_data
-from utils.nonexisting import assert_non_existing
+from ..utils.data import load_fixture, get_data
+from ..utils.nonexisting import assert_non_existing
 
 
 json1 = load_fixture('test1.json')
diff --git a/tests/comparators/test_macho.py b/tests/comparators/test_macho.py
index 49982bf..16ac6be 100644
--- a/tests/comparators/test_macho.py
+++ b/tests/comparators/test_macho.py
@@ -25,8 +25,8 @@ from diffoscope.config import Config
 from diffoscope.comparators.macho import MachoFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
 
 
 obj1 = load_fixture('test1.macho')
diff --git a/tests/comparators/test_mono.py b/tests/comparators/test_mono.py
index 7ec7e57..bc279af 100644
--- a/tests/comparators/test_mono.py
+++ b/tests/comparators/test_mono.py
@@ -23,8 +23,8 @@ from diffoscope.config import Config
 from diffoscope.comparators.mono import MonoExeFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
 
 
 # these were generated with:
diff --git a/tests/comparators/test_odt.py b/tests/comparators/test_odt.py
index 5e2bcda..fa92955 100644
--- a/tests/comparators/test_odt.py
+++ b/tests/comparators/test_odt.py
@@ -21,9 +21,9 @@ import pytest
 
 from diffoscope.comparators.odt import OdtFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
-from utils.nonexisting import assert_non_existing
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
+from ..utils.nonexisting import assert_non_existing
 
 odt1 = load_fixture('test1.odt')
 odt2 = load_fixture('test2.odt')
diff --git a/tests/comparators/test_ogg.py b/tests/comparators/test_ogg.py
index 81fa7b2..1816ac2 100644
--- a/tests/comparators/test_ogg.py
+++ b/tests/comparators/test_ogg.py
@@ -21,9 +21,9 @@ import pytest
 
 from diffoscope.comparators.ogg import OggFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
-from utils.nonexisting import assert_non_existing
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
+from ..utils.nonexisting import assert_non_existing
 
 ogg1 = load_fixture('test1.ogg')
 ogg2 = load_fixture('test2.ogg')
diff --git a/tests/comparators/test_openssh_pub_key.py b/tests/comparators/test_openssh_pub_key.py
index 3b8ce14..a1182fc 100644
--- a/tests/comparators/test_openssh_pub_key.py
+++ b/tests/comparators/test_openssh_pub_key.py
@@ -24,8 +24,8 @@ from diffoscope.config import Config
 from diffoscope.comparators.openssh import PublicKeyFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
 
 
 # Generated by: ssh-keygen -t dsa -C "Test1"
diff --git a/tests/comparators/test_pcap.py b/tests/comparators/test_pcap.py
index 3080f0d..2eca5a9 100644
--- a/tests/comparators/test_pcap.py
+++ b/tests/comparators/test_pcap.py
@@ -21,9 +21,9 @@ import pytest
 
 from diffoscope.comparators.pcap import PcapFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
-from utils.nonexisting import assert_non_existing
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
+from ..utils.nonexisting import assert_non_existing
 
 pcap1 = load_fixture('test1.pcap')
 pcap2 = load_fixture('test2.pcap')
diff --git a/tests/comparators/test_pdf.py b/tests/comparators/test_pdf.py
index 71bd38d..4c1e1b5 100644
--- a/tests/comparators/test_pdf.py
+++ b/tests/comparators/test_pdf.py
@@ -21,9 +21,9 @@ import pytest
 
 from diffoscope.comparators.pdf import PdfFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
-from utils.nonexisting import assert_non_existing
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
+from ..utils.nonexisting import assert_non_existing
 
 
 pdf1 = load_fixture('test1.pdf')
diff --git a/tests/comparators/test_pgp.py b/tests/comparators/test_pgp.py
index 096898b..05ae652 100644
--- a/tests/comparators/test_pgp.py
+++ b/tests/comparators/test_pgp.py
@@ -21,9 +21,9 @@ import pytest
 
 from diffoscope.comparators.pgp import PgpFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
-from utils.nonexisting import assert_non_existing
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
+from ..utils.nonexisting import assert_non_existing
 
 pgp1 = load_fixture('test1.pgp')
 pgp2 = load_fixture('test2.pgp')
diff --git a/tests/comparators/test_png.py b/tests/comparators/test_png.py
index 7740f11..8abb6f5 100644
--- a/tests/comparators/test_png.py
+++ b/tests/comparators/test_png.py
@@ -22,9 +22,9 @@ import pytest
 from diffoscope.comparators.png import PngFile
 from diffoscope.config import Config
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
-from utils.nonexisting import assert_non_existing
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
+from ..utils.nonexisting import assert_non_existing
 
 
 png1 = load_fixture('test1.png')
diff --git a/tests/comparators/test_ppu.py b/tests/comparators/test_ppu.py
index 83d4fa5..3b39d49 100644
--- a/tests/comparators/test_ppu.py
+++ b/tests/comparators/test_ppu.py
@@ -23,9 +23,9 @@ import subprocess
 
 from diffoscope.comparators.ppu import PpuFile
 
-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
+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
 
 
 # These test files were taken from two different builds of the Debian package
diff --git a/tests/comparators/test_ps.py b/tests/comparators/test_ps.py
index 151ddf9..fd29d86 100644
--- a/tests/comparators/test_ps.py
+++ b/tests/comparators/test_ps.py
@@ -21,9 +21,9 @@ import pytest
 
 from diffoscope.comparators.ps import PsFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
-from utils.nonexisting import assert_non_existing
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
+from ..utils.nonexisting import assert_non_existing
 
 
 ps1 = load_fixture('test1.ps')
diff --git a/tests/comparators/test_rdata.py b/tests/comparators/test_rdata.py
index a147c4c..77ba972 100644
--- a/tests/comparators/test_rdata.py
+++ b/tests/comparators/test_rdata.py
@@ -21,10 +21,10 @@ import pytest
 
 from diffoscope.comparators.gzip import GzipFile
 
-from utils import diff_ignore_line_numbers
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
-from utils.nonexisting import assert_non_existing
+from ..utils import diff_ignore_line_numbers
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
+from ..utils.nonexisting import assert_non_existing
 
 
 file1 = load_fixture('test1.rdx')
diff --git a/tests/comparators/test_rlib.py b/tests/comparators/test_rlib.py
index 5b54f52..3892bf3 100644
--- a/tests/comparators/test_rlib.py
+++ b/tests/comparators/test_rlib.py
@@ -23,11 +23,11 @@ import subprocess
 
 from diffoscope.comparators.ar import ArFile
 
-from utils import diff_ignore_line_numbers
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least, \
+from ..utils import diff_ignore_line_numbers
+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
+from ..utils.nonexisting import assert_non_existing
 
 
 
diff --git a/tests/comparators/test_rpm.py b/tests/comparators/test_rpm.py
index c374714..945d8c4 100644
--- a/tests/comparators/test_rpm.py
+++ b/tests/comparators/test_rpm.py
@@ -23,9 +23,9 @@ 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, normalize_zeros
-from utils.tools import skip_unless_tools_exist, skip_unless_module_exists
-from utils.nonexisting import assert_non_existing
+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
 
 
 try:
diff --git a/tests/comparators/test_sqlite.py b/tests/comparators/test_sqlite.py
index e5ba5e4..4a26e6a 100644
--- a/tests/comparators/test_sqlite.py
+++ b/tests/comparators/test_sqlite.py
@@ -21,9 +21,9 @@ import pytest
 
 from diffoscope.comparators.sqlite import Sqlite3Database
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
-from utils.nonexisting import assert_non_existing
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
+from ..utils.nonexisting import assert_non_existing
 
 
 sqlite3db1 = load_fixture('test1.sqlite3')
diff --git a/tests/comparators/test_squashfs.py b/tests/comparators/test_squashfs.py
index 1b379ef..3924694 100644
--- a/tests/comparators/test_squashfs.py
+++ b/tests/comparators/test_squashfs.py
@@ -22,9 +22,9 @@ import subprocess
 
 from diffoscope.comparators.squashfs import SquashfsFile
 
-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
+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
 
 
 def unsquashfs_version():
diff --git a/tests/comparators/test_symlink.py b/tests/comparators/test_symlink.py
index 5c218fe..edf3b8b 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 get_data
+from ..utils.data import get_data
 
 
 def test_destination(tmpdir):
diff --git a/tests/comparators/test_tar.py b/tests/comparators/test_tar.py
index 467cf14..08a7874 100644
--- a/tests/comparators/test_tar.py
+++ b/tests/comparators/test_tar.py
@@ -23,8 +23,8 @@ from diffoscope.config import Config
 from diffoscope.comparators.tar import TarFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils.data import load_fixture, get_data
-from utils.nonexisting import assert_non_existing
+from ..utils.data import load_fixture, get_data
+from ..utils.nonexisting import assert_non_existing
 
 
 tar1 = load_fixture('test1.tar')
diff --git a/tests/comparators/test_text.py b/tests/comparators/test_text.py
index cf21d21..ed7bf42 100644
--- a/tests/comparators/test_text.py
+++ b/tests/comparators/test_text.py
@@ -22,8 +22,8 @@ import codecs
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils.data import data, load_fixture, get_data
-from utils.nonexisting import assert_non_existing
+from ..utils.data import data, load_fixture, get_data
+from ..utils.nonexisting import assert_non_existing
 
 
 ascii1 = load_fixture('text_ascii1')
diff --git a/tests/comparators/test_utils.py b/tests/comparators/test_utils.py
index c25ec26..71118ed 100644
--- a/tests/comparators/test_utils.py
+++ b/tests/comparators/test_utils.py
@@ -24,8 +24,8 @@ from diffoscope.config import Config
 from diffoscope.difference import Difference
 from diffoscope.comparators.utils.command import Command
 
-from utils.data import data, load_fixture
-from utils.tools import tools_missing, skip_unless_tools_exist, \
+from ..utils.data import data, load_fixture
+from ..utils.tools import tools_missing, skip_unless_tools_exist, \
     skip_unless_module_exists
 
 
diff --git a/tests/comparators/test_xz.py b/tests/comparators/test_xz.py
index 2860258..073c658 100644
--- a/tests/comparators/test_xz.py
+++ b/tests/comparators/test_xz.py
@@ -24,9 +24,9 @@ from diffoscope.comparators.xz import XzFile
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
-from utils.nonexisting import assert_non_existing
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
+from ..utils.nonexisting import assert_non_existing
 
 xz1 = load_fixture('test1.xz')
 xz2 = load_fixture('test2.xz')
diff --git a/tests/comparators/test_zip.py b/tests/comparators/test_zip.py
index 6faf72a..74eb354 100644
--- a/tests/comparators/test_zip.py
+++ b/tests/comparators/test_zip.py
@@ -21,9 +21,9 @@ import pytest
 
 from diffoscope.comparators.zip import ZipFile, MozillaZipFile
 
-from utils.data import load_fixture, get_data
-from utils.tools import skip_unless_tools_exist
-from utils.nonexisting import assert_non_existing
+from ..utils.data import load_fixture, get_data
+from ..utils.tools import skip_unless_tools_exist
+from ..utils.nonexisting import assert_non_existing
 
 
 zip1 = load_fixture('test1.zip')
diff --git a/tests/test_presenters.py b/tests/test_presenters.py
index e267eb8..b58605d 100644
--- a/tests/test_presenters.py
+++ b/tests/test_presenters.py
@@ -23,48 +23,30 @@ import pytest
 
 from diffoscope.main import main
 
+from .utils.data import cwd_data, get_data
+
 re_html = re.compile(r'.*<body(?P<body>.*)<div class="footer">', re.MULTILINE | re.DOTALL)
 DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')
 
 
 def run(capsys, *args):
-    with pytest.raises(SystemExit) as exc:
-        prev = os.getcwd()
-        os.chdir(DATA_DIR)
-
-        try:
-            main(args + ('test1.tar', 'test2.tar'))
-        finally:
-            os.chdir(prev)
-
+    with pytest.raises(SystemExit) as exc, cwd_data():
+        main(args + ('test1.tar', 'test2.tar'))
     out, err = capsys.readouterr()
 
     assert err == ''
     assert exc.value.code == 1
-
     return out
 
 def run_images(capsys, *args):
-    with pytest.raises(SystemExit) as exc:
-        prev = os.getcwd()
-        os.chdir(DATA_DIR)
-
-        try:
-            main(args + ('test1.png', 'test2.png'))
-        finally:
-            os.chdir(prev)
-
+    with pytest.raises(SystemExit) as exc, cwd_data():
+        main(args + ('test1.png', 'test2.png'))
     out, err = capsys.readouterr()
 
     assert err == ''
     assert exc.value.code == 1
-
     return out
 
-def data(filename):
-    with open(os.path.join(DATA_DIR, filename), encoding='utf-8') as f:
-        return f.read()
-
 def extract_body(val):
     """
     Extract the salient parts of HTML fixtures that won't change between
@@ -81,12 +63,12 @@ def extract_body(val):
 def test_text_option_is_default(capsys):
     out = run(capsys)
 
-    assert out == data('output.txt')
+    assert out == get_data('output.txt')
 
 def test_text_option_color(capsys):
     out = run(capsys, '--text-color=always')
 
-    assert out == data('output.colored.txt')
+    assert out == get_data('output.colored.txt')
 
 def test_text_option_with_file(tmpdir, capsys):
     report_path = str(tmpdir.join('report.txt'))
@@ -96,32 +78,32 @@ def test_text_option_with_file(tmpdir, capsys):
     assert out == ''
 
     with open(report_path, 'r', encoding='utf-8') as f:
-        assert f.read() == data('output.txt')
+        assert f.read() == get_data('output.txt')
 
 def test_text_option_with_stdiout(capsys):
     out = run(capsys, '--text', '-')
 
-    assert out == data('output.txt')
+    assert out == get_data('output.txt')
 
 def test_markdown(capsys):
     out = run(capsys, '--markdown', '-')
 
-    assert out == data('output.md')
+    assert out == get_data('output.md')
 
 def test_restructuredtext(capsys):
     out = run(capsys, '--restructured-text', '-')
 
-    assert out == data('output.rst')
+    assert out == get_data('output.rst')
 
 def test_json(capsys):
     out = run(capsys, '--json', '-')
 
-    assert out == data('output.json')
+    assert out == get_data('output.json')
 
 def test_no_report_option(capsys):
     out = run(capsys)
 
-    assert out == data('output.txt')
+    assert out == get_data('output.txt')
 
 def test_html_option_with_file(tmpdir, capsys):
     report_path = str(tmpdir.join('report.html'))
@@ -130,7 +112,7 @@ def test_html_option_with_file(tmpdir, capsys):
 
     assert out == ''
     with open(report_path, 'r', encoding='utf-8') as f:
-        assert extract_body(f.read()) == extract_body(data('output.html'))
+        assert extract_body(f.read()) == extract_body(get_data('output.html'))
 
 def test_html_visuals(tmpdir, capsys):
     report_path = str(tmpdir.join('report.html'))
@@ -150,9 +132,9 @@ def test_htmldir_option(tmpdir, capsys):
     assert out == ''
     assert os.path.isdir(html_dir)
     with open(os.path.join(html_dir, 'index.html'), 'r', encoding='utf-8') as f:
-        assert extract_body(f.read()) == extract_body(data('index.html'))
+        assert extract_body(f.read()) == extract_body(get_data('index.html'))
 
 def test_html_option_with_stdout(capsys):
     out = run(capsys, '--html', '-')
 
-    assert extract_body(out) == extract_body(data('output.html'))
+    assert extract_body(out) == extract_body(get_data('output.html'))
diff --git a/tests/test_progress.py b/tests/test_progress.py
index 9053709..bb94117 100644
--- a/tests/test_progress.py
+++ b/tests/test_progress.py
@@ -25,7 +25,7 @@ import pytest
 from diffoscope.main import main
 from diffoscope.progress import ProgressManager, StatusFD
 
-from comparators.utils.tools import skip_unless_module_exists
+from .utils.tools import skip_unless_module_exists
 
 TEST_TAR1_PATH = os.path.join(os.path.dirname(__file__), 'data', 'test1.tar')
 TEST_TAR2_PATH = os.path.join(os.path.dirname(__file__), 'data', 'test2.tar')
diff --git a/tests/test_quines.py b/tests/test_quines.py
index 9cd3418..14e00c3 100644
--- a/tests/test_quines.py
+++ b/tests/test_quines.py
@@ -23,7 +23,7 @@ from diffoscope.comparators.deb import DebFile
 from diffoscope.comparators.zip import ZipFile
 from diffoscope.comparators.gzip import GzipFile
 
-from comparators.utils.data import load_fixture, get_data
+from .utils.data import load_fixture, get_data
 
 quine1 = load_fixture('quine.gz')
 quine2 = load_fixture('quine.zip')
diff --git a/tests/test_readers.py b/tests/test_readers.py
index a765ecd..9b48931 100644
--- a/tests/test_readers.py
+++ b/tests/test_readers.py
@@ -25,7 +25,7 @@ from diffoscope.main import main
 from diffoscope.comparators.utils.compare import compare_root_paths
 from diffoscope.readers import load_diff_from_path
 
-from comparators.utils.data import cwd_data, get_data
+from .utils.data import cwd_data, get_data
 
 
 def run_read_write(capsys, diff, *args):
diff --git a/tests/comparators/utils/__init__.py b/tests/utils/__init__.py
similarity index 100%
rename from tests/comparators/utils/__init__.py
rename to tests/utils/__init__.py
diff --git a/tests/comparators/utils/data.py b/tests/utils/data.py
similarity index 99%
rename from tests/comparators/utils/data.py
rename to tests/utils/data.py
index d2420d1..dc43f0d 100644
--- a/tests/comparators/utils/data.py
+++ b/tests/utils/data.py
@@ -40,7 +40,6 @@ def init_fixture(filename):
 def data(filename):
     return os.path.join(
         os.path.dirname(os.path.dirname(__file__)),
-        '..',
         'data',
         filename,
     )
diff --git a/tests/comparators/utils/nonexisting.py b/tests/utils/nonexisting.py
similarity index 100%
rename from tests/comparators/utils/nonexisting.py
rename to tests/utils/nonexisting.py
diff --git a/tests/comparators/utils/tools.py b/tests/utils/tools.py
similarity index 100%
rename from tests/comparators/utils/tools.py
rename to tests/utils/tools.py

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


More information about the diffoscope mailing list