[diffoscope] 01/05: tests/comparators/utils: turn into a packages with smaller modules

Mattia Rizzolo mattia at debian.org
Mon Jan 16 10:47:10 CET 2017


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

mattia pushed a commit to branch wip/tests-dry
in repository diffoscope.

commit 6ab93c10447b4d391e866b1bc6342573debfcff8
Author: Mattia Rizzolo <mattia at debian.org>
Date:   Sun Jan 15 14:28:45 2017 +0100

    tests/comparators/utils: turn into a packages with smaller modules
---
 tests/comparators/test_apk.py                      |  5 ++-
 tests/comparators/test_binary.py                   | 11 ++++--
 tests/comparators/test_bzip2.py                    |  5 ++-
 tests/comparators/test_cbfs.py                     |  5 ++-
 tests/comparators/test_cpio.py                     |  5 ++-
 tests/comparators/test_deb.py                      |  2 +-
 tests/comparators/test_debian.py                   |  3 +-
 tests/comparators/test_dex.py                      |  5 ++-
 tests/comparators/test_directory.py                |  3 +-
 tests/comparators/test_elf.py                      |  4 +-
 tests/comparators/test_epub.py                     |  5 ++-
 tests/comparators/test_fonts.py                    |  3 +-
 tests/comparators/test_fsimage.py                  |  4 +-
 tests/comparators/test_gettext.py                  |  4 +-
 tests/comparators/test_git.py                      |  3 +-
 tests/comparators/test_gzip.py                     |  3 +-
 tests/comparators/test_haskell.py                  |  4 +-
 tests/comparators/test_icc.py                      |  4 +-
 tests/comparators/test_ico_image.py                |  5 ++-
 tests/comparators/test_ipk.py                      |  3 +-
 tests/comparators/test_iso9660.py                  |  4 +-
 tests/comparators/test_java.py                     |  4 +-
 tests/comparators/test_javascript.py               |  4 +-
 tests/comparators/test_jpeg_image.py               |  5 ++-
 tests/comparators/test_json.py                     |  4 +-
 tests/comparators/test_macho.py                    |  4 +-
 tests/comparators/test_mono.py                     |  4 +-
 tests/comparators/test_openssh_pub_key.py          |  5 ++-
 tests/comparators/test_pdf.py                      |  6 ++-
 tests/comparators/test_png.py                      |  6 ++-
 tests/comparators/test_ppu.py                      |  6 ++-
 tests/comparators/test_ps.py                       |  6 ++-
 tests/comparators/test_rlib.py                     |  9 +++--
 tests/comparators/test_rpm.py                      |  6 ++-
 tests/comparators/test_sqlite.py                   |  6 ++-
 tests/comparators/test_squashfs.py                 |  6 ++-
 tests/comparators/test_tar.py                      |  4 +-
 tests/comparators/test_text.py                     |  4 +-
 tests/comparators/test_utils.py                    |  6 ++-
 tests/comparators/test_xz.py                       |  6 ++-
 tests/comparators/test_zip.py                      |  6 ++-
 .../comparators/{test_git.py => utils/__init__.py} | 27 +++----------
 tests/comparators/{test_git.py => utils/data.py}   | 34 ++++++++---------
 .../{test_icc.py => utils/nonexisting.py}          | 39 ++++++-------------
 tests/comparators/{utils.py => utils/tools.py}     | 44 +---------------------
 45 files changed, 170 insertions(+), 171 deletions(-)

diff --git a/tests/comparators/test_apk.py b/tests/comparators/test_apk.py
index 7c539d1..f57ef7e 100644
--- a/tests/comparators/test_apk.py
+++ b/tests/comparators/test_apk.py
@@ -21,8 +21,9 @@ import pytest
 
 from diffoscope.comparators.apk import ApkFile
 
-from utils import skip_unless_tools_exist, data, load_fixture, \
-    assert_non_existing
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+from utils.nonexisting import assert_non_existing
 
 apk1 = load_fixture(data('test1.apk'))
 apk2 = load_fixture(data('test2.apk'))
diff --git a/tests/comparators/test_binary.py b/tests/comparators/test_binary.py
index dbd09d2..759c67d 100644
--- a/tests/comparators/test_binary.py
+++ b/tests/comparators/test_binary.py
@@ -17,9 +17,13 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
 
+import os.path
 import pytest
 import subprocess
 
+from os import mkdir, symlink
+from tempfile import TemporaryDirectory
+
 from diffoscope.tools import tool_required
 from diffoscope.exc import RequiredToolNotFound
 from diffoscope.difference import Difference
@@ -28,10 +32,9 @@ from diffoscope.comparators.utils.file import File
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.utils.compare import Xxd
 
-from utils import skip_unless_tools_exist, data, load_fixture
-from os import mkdir, symlink
-from tempfile import TemporaryDirectory
-import os.path
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+
 
 TEST_FILE1_PATH = data('binary1')
 TEST_FILE2_PATH = data('binary2')
diff --git a/tests/comparators/test_bzip2.py b/tests/comparators/test_bzip2.py
index 41c6f35..e749b4e 100644
--- a/tests/comparators/test_bzip2.py
+++ b/tests/comparators/test_bzip2.py
@@ -24,8 +24,9 @@ from diffoscope.comparators.bzip2 import Bzip2File
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils import skip_unless_tools_exist, data, load_fixture, \
-    assert_non_existing
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+from utils.nonexisting import assert_non_existing
 
 
 TEST_FILE1_PATH = data('test1.bz2')
diff --git a/tests/comparators/test_cbfs.py b/tests/comparators/test_cbfs.py
index 9043559..85ddbca 100644
--- a/tests/comparators/test_cbfs.py
+++ b/tests/comparators/test_cbfs.py
@@ -26,7 +26,10 @@ from diffoscope.comparators.cbfs import CbfsFile
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils import skip_unless_tools_exist, data, assert_non_existing
+from utils.data import data
+from utils.tools import skip_unless_tools_exist
+from utils.nonexisting import assert_non_existing
+
 
 TEST_FILE1_PATH = data('text_ascii1')
 TEST_FILE2_PATH = data('text_ascii2')
diff --git a/tests/comparators/test_cpio.py b/tests/comparators/test_cpio.py
index cd68482..a1eba51 100644
--- a/tests/comparators/test_cpio.py
+++ b/tests/comparators/test_cpio.py
@@ -21,8 +21,9 @@ import pytest
 
 from diffoscope.comparators.cpio import CpioFile
 
-from utils import skip_unless_tools_exist, data, load_fixture, \
-    assert_non_existing
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+from utils.nonexisting import assert_non_existing
 
 
 cpio1 = load_fixture(data('test1.cpio'))
diff --git a/tests/comparators/test_deb.py b/tests/comparators/test_deb.py
index cbb0302..8684be2 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 import data, load_fixture
+from utils.data import data, load_fixture
 
 
 deb1 = load_fixture(data('test1.deb'))
diff --git a/tests/comparators/test_debian.py b/tests/comparators/test_debian.py
index de2d052..c8860a5 100644
--- a/tests/comparators/test_debian.py
+++ b/tests/comparators/test_debian.py
@@ -26,7 +26,8 @@ from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils import data, assert_non_existing
+from utils.data import data
+from utils.nonexisting import assert_non_existing
 
 try:
     from diffoscope.comparators.debian import DotChangesFile, DotDscFile, \
diff --git a/tests/comparators/test_dex.py b/tests/comparators/test_dex.py
index 788f836..647db5f 100644
--- a/tests/comparators/test_dex.py
+++ b/tests/comparators/test_dex.py
@@ -24,7 +24,10 @@ from diffoscope.config import Config
 from diffoscope.comparators.dex import DexFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils import skip_unless_tools_exist, data, load_fixture, skip_unless_tool_is_at_least
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
+from utils.nonexisting import assert_non_existing
+
 from test_java import javap_version
 
 
diff --git a/tests/comparators/test_directory.py b/tests/comparators/test_directory.py
index e83c663..6f09a9d 100644
--- a/tests/comparators/test_directory.py
+++ b/tests/comparators/test_directory.py
@@ -24,7 +24,8 @@ import pytest
 from diffoscope.presenters.text import output_text
 from diffoscope.comparators.directory import compare_directories
 
-from utils import data
+from utils.data import data
+
 
 TEST_FILE1_PATH = data('text_ascii1')
 TEST_FILE2_PATH = data('text_ascii2')
diff --git a/tests/comparators/test_elf.py b/tests/comparators/test_elf.py
index 362d893..1f10945 100644
--- a/tests/comparators/test_elf.py
+++ b/tests/comparators/test_elf.py
@@ -28,7 +28,9 @@ from diffoscope.comparators.directory import FilesystemDirectory
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils import skip_unless_tools_exist, data, load_fixture
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+
 
 try:
     import diffoscope.comparators.debian # noqa
diff --git a/tests/comparators/test_epub.py b/tests/comparators/test_epub.py
index 1e64d45..17a3605 100644
--- a/tests/comparators/test_epub.py
+++ b/tests/comparators/test_epub.py
@@ -23,7 +23,10 @@ from diffoscope.config import Config
 from diffoscope.comparators.zip import ZipFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils import skip_unless_tools_exist, data, load_fixture
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+from utils.nonexisting import assert_non_existing
+
 
 epub1 = load_fixture(data('test1.epub'))
 epub2 = load_fixture(data('test2.epub'))
diff --git a/tests/comparators/test_fonts.py b/tests/comparators/test_fonts.py
index 8bbbb1c..7ac58a1 100644
--- a/tests/comparators/test_fonts.py
+++ b/tests/comparators/test_fonts.py
@@ -23,7 +23,8 @@ from diffoscope.config import Config
 from diffoscope.comparators.fonts import TtfFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils import skip_unless_tools_exist, data, load_fixture
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
 
 
 ttf1 = load_fixture(data('Samyak-Malayalam1.ttf'))
diff --git a/tests/comparators/test_fsimage.py b/tests/comparators/test_fsimage.py
index f917376..2a5addd 100644
--- a/tests/comparators/test_fsimage.py
+++ b/tests/comparators/test_fsimage.py
@@ -23,7 +23,9 @@ from diffoscope.config import Config
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.fsimage import FsImageFile
 
-from utils import skip_unless_tools_exist, data, load_fixture
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+
 
 try:
     import guestfs
diff --git a/tests/comparators/test_gettext.py b/tests/comparators/test_gettext.py
index 3071d1e..3980e17 100644
--- a/tests/comparators/test_gettext.py
+++ b/tests/comparators/test_gettext.py
@@ -24,7 +24,9 @@ from diffoscope.config import Config
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.gettext import MoFile
 
-from utils import skip_unless_tools_exist, data, load_fixture
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+
 
 mo1 = load_fixture(data('test1.mo'))
 mo2 = load_fixture(data('test2.mo'))
diff --git a/tests/comparators/test_git.py b/tests/comparators/test_git.py
index a254bbf..e180872 100644
--- a/tests/comparators/test_git.py
+++ b/tests/comparators/test_git.py
@@ -21,7 +21,8 @@ import pytest
 
 from diffoscope.comparators.git import GitIndexFile
 
-from utils import data, load_fixture
+from utils.data import data, load_fixture
+
 
 git1 = load_fixture(data('test1.git-index'))
 git2 = load_fixture(data('test2.git-index'))
diff --git a/tests/comparators/test_gzip.py b/tests/comparators/test_gzip.py
index 4c60287..b14d2a6 100644
--- a/tests/comparators/test_gzip.py
+++ b/tests/comparators/test_gzip.py
@@ -26,7 +26,8 @@ from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils import data, load_fixture
+from utils.data import data, load_fixture
+
 
 TEST_FILE1_PATH = data('test1.gz')
 TEST_FILE2_PATH = data('test2.gz')
diff --git a/tests/comparators/test_haskell.py b/tests/comparators/test_haskell.py
index 7ca18b5..b962bda 100644
--- a/tests/comparators/test_haskell.py
+++ b/tests/comparators/test_haskell.py
@@ -22,7 +22,9 @@ import pytest
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.haskell import HiFile
 
-from utils import skip_unless_tools_exist, data, load_fixture
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+
 
 haskell1 = load_fixture(data('test1.hi'))
 haskell2 = load_fixture(data('test2.hi'))
diff --git a/tests/comparators/test_icc.py b/tests/comparators/test_icc.py
index 9628595..db301bc 100644
--- a/tests/comparators/test_icc.py
+++ b/tests/comparators/test_icc.py
@@ -23,7 +23,9 @@ from diffoscope.config import Config
 from diffoscope.comparators.icc import IccFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils import skip_unless_tools_exist, data, load_fixture
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+
 
 icc1 = load_fixture(data('test1.icc'))
 icc2 = load_fixture(data('test2.icc'))
diff --git a/tests/comparators/test_ico_image.py b/tests/comparators/test_ico_image.py
index e50afd4..1bd706b 100644
--- a/tests/comparators/test_ico_image.py
+++ b/tests/comparators/test_ico_image.py
@@ -22,10 +22,11 @@ import pytest
 from diffoscope.config import Config
 from diffoscope.comparators.image import ICOImageFile
 
-from utils import skip_unless_tools_exist, data, load_fixture, \
-    skip_unless_tool_is_at_least
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
 from test_jpeg_image import identify_version
 
+
 image1 = load_fixture(data('test1.ico'))
 image2 = load_fixture(data('test2.ico'))
 image1_meta = load_fixture(data('test1_meta.ico'))
diff --git a/tests/comparators/test_ipk.py b/tests/comparators/test_ipk.py
index 3789622..529cbfa 100644
--- a/tests/comparators/test_ipk.py
+++ b/tests/comparators/test_ipk.py
@@ -23,7 +23,8 @@ from diffoscope.config import Config
 from diffoscope.comparators.ipk import IpkFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils import data, load_fixture
+from utils.data import data, load_fixture
+
 
 ipk1 = load_fixture(data('base-files_157-r45695_ar71xx.ipk'))
 ipk2 = load_fixture(data('base-files_157-r45918_ar71xx.ipk'))
diff --git a/tests/comparators/test_iso9660.py b/tests/comparators/test_iso9660.py
index 7748027..4deb805 100644
--- a/tests/comparators/test_iso9660.py
+++ b/tests/comparators/test_iso9660.py
@@ -23,7 +23,9 @@ from diffoscope.config import Config
 from diffoscope.comparators.missing_file import MissingFile
 from diffoscope.comparators.iso9660 import Iso9660File
 
-from utils import skip_unless_tools_exist, data, load_fixture
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+
 
 iso1 = load_fixture(data('test1.iso'))
 iso2 = load_fixture(data('test2.iso'))
diff --git a/tests/comparators/test_java.py b/tests/comparators/test_java.py
index 0a6a941..975c593 100644
--- a/tests/comparators/test_java.py
+++ b/tests/comparators/test_java.py
@@ -24,7 +24,9 @@ from diffoscope.config import Config
 from diffoscope.comparators.java import ClassFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils import skip_unless_tools_exist, data, load_fixture, skip_unless_tool_is_at_least
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
+
 
 class1 = load_fixture(data('Test1.class'))
 class2 = load_fixture(data('Test2.class'))
diff --git a/tests/comparators/test_javascript.py b/tests/comparators/test_javascript.py
index 9324988..1d26e43 100644
--- a/tests/comparators/test_javascript.py
+++ b/tests/comparators/test_javascript.py
@@ -23,7 +23,9 @@ from diffoscope.config import Config
 from diffoscope.comparators.javascript import JavaScriptFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils import skip_unless_tools_exist, data, load_fixture
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+
 
 javascript1 = load_fixture(data('test1.js'))
 javascript2 = load_fixture(data('test2.js'))
diff --git a/tests/comparators/test_jpeg_image.py b/tests/comparators/test_jpeg_image.py
index 194bc64..fb455eb 100644
--- a/tests/comparators/test_jpeg_image.py
+++ b/tests/comparators/test_jpeg_image.py
@@ -24,8 +24,9 @@ from diffoscope.config import Config
 from diffoscope.comparators.image import JPEGImageFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils import skip_unless_tools_exist, data, load_fixture, \
-    skip_unless_tool_is_at_least
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
+
 
 image1 = load_fixture(data('test1.jpg'))
 image2 = load_fixture(data('test2.jpg'))
diff --git a/tests/comparators/test_json.py b/tests/comparators/test_json.py
index 0344fda..339128b 100644
--- a/tests/comparators/test_json.py
+++ b/tests/comparators/test_json.py
@@ -21,7 +21,9 @@ import pytest
 
 from diffoscope.comparators.json import JSONFile
 
-from utils import data, load_fixture, assert_non_existing
+from utils.data import data, load_fixture
+from utils.nonexisting import assert_non_existing
+
 
 json1 = load_fixture(data('test1.json'))
 json2 = load_fixture(data('test2.json'))
diff --git a/tests/comparators/test_macho.py b/tests/comparators/test_macho.py
index b161573..ae3d0d1 100644
--- a/tests/comparators/test_macho.py
+++ b/tests/comparators/test_macho.py
@@ -25,7 +25,9 @@ from diffoscope.config import Config
 from diffoscope.comparators.macho import MachoFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils import skip_unless_tools_exist, data, load_fixture
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+
 
 obj1 = load_fixture(data('test1.macho'))
 obj2 = load_fixture(data('test2.macho'))
diff --git a/tests/comparators/test_mono.py b/tests/comparators/test_mono.py
index c8d3a7d..96ced6e 100644
--- a/tests/comparators/test_mono.py
+++ b/tests/comparators/test_mono.py
@@ -23,7 +23,9 @@ from diffoscope.config import Config
 from diffoscope.comparators.mono import MonoExeFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils import skip_unless_tools_exist, data, load_fixture
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+
 
 # these were generated with:
 
diff --git a/tests/comparators/test_openssh_pub_key.py b/tests/comparators/test_openssh_pub_key.py
index 1ddc882..e63d4e2 100644
--- a/tests/comparators/test_openssh_pub_key.py
+++ b/tests/comparators/test_openssh_pub_key.py
@@ -24,8 +24,9 @@ from diffoscope.config import Config
 from diffoscope.comparators.openssh import PublicKeyFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils import skip_unless_tool_is_at_least, skip_unless_tools_exist, \
-    load_fixture, data
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
+
 
 # Generated by: ssh-keygen -t dsa -C "Test1"
 opensshpubkey1 = load_fixture(data('test_openssh_pub_key1.pub'))
diff --git a/tests/comparators/test_pdf.py b/tests/comparators/test_pdf.py
index 590590d..6b166b3 100644
--- a/tests/comparators/test_pdf.py
+++ b/tests/comparators/test_pdf.py
@@ -21,8 +21,10 @@ import pytest
 
 from diffoscope.comparators.pdf import PdfFile
 
-from utils import skip_unless_tools_exist, data, load_fixture, \
-    assert_non_existing
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+from utils.nonexisting import assert_non_existing
+
 
 pdf1 = load_fixture(data('test1.pdf'))
 pdf2 = load_fixture(data('test2.pdf'))
diff --git a/tests/comparators/test_png.py b/tests/comparators/test_png.py
index 6722744..8541911 100644
--- a/tests/comparators/test_png.py
+++ b/tests/comparators/test_png.py
@@ -21,8 +21,10 @@ import pytest
 
 from diffoscope.comparators.png import PngFile
 
-from utils import skip_unless_tools_exist, data, load_fixture, \
-    assert_non_existing
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+from utils.nonexisting import assert_non_existing
+
 
 png1 = load_fixture(data('test1.png'))
 png2 = load_fixture(data('test2.png'))
diff --git a/tests/comparators/test_ppu.py b/tests/comparators/test_ppu.py
index 5bcd456..5b7c3b9 100644
--- a/tests/comparators/test_ppu.py
+++ b/tests/comparators/test_ppu.py
@@ -23,8 +23,10 @@ import subprocess
 
 from diffoscope.comparators.ppu import PpuFile
 
-from utils import skip_unless_tools_exist, data, load_fixture, \
-    assert_non_existing, skip_unless_tool_is_at_least
+from utils.data import data, load_fixture
+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
 # fp-units-castle-game-engine (version 5.1.1-2 on amd64) on the Debian
diff --git a/tests/comparators/test_ps.py b/tests/comparators/test_ps.py
index d4761c8..71cd8eb 100644
--- a/tests/comparators/test_ps.py
+++ b/tests/comparators/test_ps.py
@@ -21,8 +21,10 @@ import pytest
 
 from diffoscope.comparators.ps import PsFile
 
-from utils import skip_unless_tools_exist, data, load_fixture, \
-    assert_non_existing
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+from utils.nonexisting import assert_non_existing
+
 
 ps1 = load_fixture(data('test1.ps'))
 ps2 = load_fixture(data('test2.ps'))
diff --git a/tests/comparators/test_rlib.py b/tests/comparators/test_rlib.py
index 93699fc..1dd7897 100644
--- a/tests/comparators/test_rlib.py
+++ b/tests/comparators/test_rlib.py
@@ -23,9 +23,12 @@ import subprocess
 
 from diffoscope.comparators.ar import ArFile
 
-from utils import skip_unless_tools_exist, skip_unless_tool_is_at_least, \
-    skip_unless_tools_exist, data, load_fixture, assert_non_existing, \
-    diff_ignore_line_numbers
+from utils import diff_ignore_line_numbers
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
+from utils.nonexisting import assert_non_existing
+
+
 
 rlib1 = load_fixture(data('test1.rlib'))
 rlib2 = load_fixture(data('test2.rlib'))
diff --git a/tests/comparators/test_rpm.py b/tests/comparators/test_rpm.py
index 1b43007..d65770d 100644
--- a/tests/comparators/test_rpm.py
+++ b/tests/comparators/test_rpm.py
@@ -19,8 +19,10 @@
 
 import pytest
 
-from utils import skip_unless_tools_exist, data, load_fixture, \
-    assert_non_existing
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+from utils.nonexisting import assert_non_existing
+
 
 try:
     from diffoscope.comparators.rpm import RpmFile
diff --git a/tests/comparators/test_sqlite.py b/tests/comparators/test_sqlite.py
index 52395fc..3fff569 100644
--- a/tests/comparators/test_sqlite.py
+++ b/tests/comparators/test_sqlite.py
@@ -21,8 +21,10 @@ import pytest
 
 from diffoscope.comparators.sqlite import Sqlite3Database
 
-from utils import skip_unless_tools_exist, data, load_fixture, \
-    assert_non_existing
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+from utils.nonexisting import assert_non_existing
+
 
 sqlite3db1 = load_fixture(data('test1.sqlite3'))
 sqlite3db2 = load_fixture(data('test2.sqlite3'))
diff --git a/tests/comparators/test_squashfs.py b/tests/comparators/test_squashfs.py
index 5c407b5..00b2839 100644
--- a/tests/comparators/test_squashfs.py
+++ b/tests/comparators/test_squashfs.py
@@ -22,8 +22,10 @@ import subprocess
 
 from diffoscope.comparators.squashfs import SquashfsFile
 
-from utils import skip_unless_tools_exist, data, load_fixture, \
-    assert_non_existing, skip_unless_tool_is_at_least
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
+from utils.nonexisting import assert_non_existing
+
 
 def unsquashfs_version():
     # first line of 'unsquashfs -version' looks like:
diff --git a/tests/comparators/test_tar.py b/tests/comparators/test_tar.py
index 98fab9b..3ddfb58 100644
--- a/tests/comparators/test_tar.py
+++ b/tests/comparators/test_tar.py
@@ -23,7 +23,9 @@ from diffoscope.config import Config
 from diffoscope.comparators.tar import TarFile
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils import data, load_fixture, assert_non_existing
+from utils.data import data, load_fixture
+from utils.nonexisting import assert_non_existing
+
 
 tar1 = load_fixture(data('test1.tar'))
 tar2 = load_fixture(data('test2.tar'))
diff --git a/tests/comparators/test_text.py b/tests/comparators/test_text.py
index bd9b33b..45babfc 100644
--- a/tests/comparators/test_text.py
+++ b/tests/comparators/test_text.py
@@ -22,7 +22,9 @@ import codecs
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils import data, load_fixture, assert_non_existing
+from utils.data import data, load_fixture
+from utils.nonexisting import assert_non_existing
+
 
 ascii1 = load_fixture(data('text_ascii1'))
 ascii2 = load_fixture(data('text_ascii2'))
diff --git a/tests/comparators/test_utils.py b/tests/comparators/test_utils.py
index af90477..02d2c94 100644
--- a/tests/comparators/test_utils.py
+++ b/tests/comparators/test_utils.py
@@ -24,8 +24,10 @@ from diffoscope.config import Config
 from diffoscope.difference import Difference
 from diffoscope.comparators.utils.command import Command
 
-from utils import tools_missing, skip_unless_tools_exist, data, load_fixture, \
-    skip_unless_tool_is_at_least
+from utils.data import data, load_fixture
+from utils.tools import tools_missing, skip_unless_tools_exist
+from utils.nonexisting import assert_non_existing
+
 
 try:
     import tlsh # noqa
diff --git a/tests/comparators/test_xz.py b/tests/comparators/test_xz.py
index f0df4e6..11051d7 100644
--- a/tests/comparators/test_xz.py
+++ b/tests/comparators/test_xz.py
@@ -24,8 +24,10 @@ from diffoscope.comparators.xz import XzFile
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.utils.specialize import specialize
 
-from utils import skip_unless_tools_exist, data, load_fixture, \
-    assert_non_existing
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+from utils.nonexisting import assert_non_existing
+
 
 TEST_FILE1_PATH = data('test1.xz')
 TEST_FILE2_PATH = data('test2.xz')
diff --git a/tests/comparators/test_zip.py b/tests/comparators/test_zip.py
index c4a401a..b28d7d7 100644
--- a/tests/comparators/test_zip.py
+++ b/tests/comparators/test_zip.py
@@ -21,8 +21,10 @@ import pytest
 
 from diffoscope.comparators.zip import ZipFile, MozillaZipFile
 
-from utils import skip_unless_tools_exist, data, load_fixture, \
-    assert_non_existing
+from utils.data import data, load_fixture
+from utils.tools import skip_unless_tools_exist
+from utils.nonexisting import assert_non_existing
+
 
 zip1 = load_fixture(data('test1.zip'))
 zip2 = load_fixture(data('test2.zip'))
diff --git a/tests/comparators/test_git.py b/tests/comparators/utils/__init__.py
similarity index 53%
copy from tests/comparators/test_git.py
copy to tests/comparators/utils/__init__.py
index a254bbf..d1b43d8 100644
--- a/tests/comparators/test_git.py
+++ b/tests/comparators/utils/__init__.py
@@ -2,7 +2,7 @@
 #
 # diffoscope: in-depth comparison of files, archives, and directories
 #
-# Copyright © 2016 Chris Lamb <lamby at debian.org>
+# Copyright © 2015 Jérémy Bobbio <lunar at debian.org>
 #
 # diffoscope is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,26 +17,9 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
 
-import pytest
+import re
 
-from diffoscope.comparators.git import GitIndexFile
+re_diff_line_numbers = re.compile(r"(^|\n)@@ -(\d+),(\d+) \+(\d+),(\d+) @@(?=\n|$)")
 
-from utils import data, load_fixture
-
-git1 = load_fixture(data('test1.git-index'))
-git2 = load_fixture(data('test2.git-index'))
-
-def test_identification(git1):
-    assert isinstance(git1, GitIndexFile)
-
-def test_no_differences(git1):
-    assert git1.compare(git1) is None
-
- at pytest.fixture
-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()
-    assert differences[0].unified_diff == expected_diff
+def diff_ignore_line_numbers(diff):
+    return re_diff_line_numbers.sub(r"\1@@ -XX,XX +XX,XX @@", diff)
diff --git a/tests/comparators/test_git.py b/tests/comparators/utils/data.py
similarity index 54%
copy from tests/comparators/test_git.py
copy to tests/comparators/utils/data.py
index a254bbf..5a8df13 100644
--- a/tests/comparators/test_git.py
+++ b/tests/comparators/utils/data.py
@@ -2,7 +2,8 @@
 #
 # diffoscope: in-depth comparison of files, archives, and directories
 #
-# Copyright © 2016 Chris Lamb <lamby at debian.org>
+# Copyright © 2015      Jérémy Bobbio <lunar at debian.org>
+#             2016-2017 Mattia Rizzolo <mattia at debian.org>
 #
 # diffoscope is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,26 +18,23 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
 
+import os
 import pytest
 
-from diffoscope.comparators.git import GitIndexFile
+from diffoscope.comparators.binary import FilesystemFile
+from diffoscope.comparators.utils.specialize import specialize
 
-from utils import data, load_fixture
 
-git1 = load_fixture(data('test1.git-index'))
-git2 = load_fixture(data('test2.git-index'))
+def load_fixture(filename):
+    return pytest.fixture(
+        lambda: specialize(FilesystemFile(filename))
+    )
 
-def test_identification(git1):
-    assert isinstance(git1, GitIndexFile)
 
-def test_no_differences(git1):
-    assert git1.compare(git1) is None
-
- at pytest.fixture
-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()
-    assert differences[0].unified_diff == expected_diff
+def data(filename):
+    return os.path.join(
+        os.path.dirname(os.path.dirname(__file__)),
+        '..',
+        'data',
+        filename,
+    )
diff --git a/tests/comparators/test_icc.py b/tests/comparators/utils/nonexisting.py
similarity index 51%
copy from tests/comparators/test_icc.py
copy to tests/comparators/utils/nonexisting.py
index 9628595..2e3b07c 100644
--- a/tests/comparators/test_icc.py
+++ b/tests/comparators/utils/nonexisting.py
@@ -2,7 +2,8 @@
 #
 # diffoscope: in-depth comparison of files, archives, and directories
 #
-# Copyright © 2016 Jérémy Bobbio <lunar at debian.org>
+# Copyright © 2015      Jérémy Bobbio <lunar at debian.org>
+#             2016-2017 Mattia Rizzolo <mattia at debian.org>
 #
 # diffoscope is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,37 +18,21 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
 
-import pytest
-
 from diffoscope.config import Config
-from diffoscope.comparators.icc import IccFile
+from diffoscope.presenters.html import output_html
+from diffoscope.presenters.text import output_text
 from diffoscope.comparators.missing_file import MissingFile
 
-from utils import skip_unless_tools_exist, data, load_fixture
-
-icc1 = load_fixture(data('test1.icc'))
-icc2 = load_fixture(data('test2.icc'))
-
-def test_identification(icc1):
-    assert isinstance(icc1, IccFile)
 
-def test_no_differences(icc1):
-    difference = icc1.compare(icc1)
-    assert difference is None
+def assert_non_existing(monkeypatch, fixture, has_null_source=True, has_details=True):
+    monkeypatch.setattr(Config(), 'new_file', True)
+    assert Config().new_file, "didnt get patched"
 
- at pytest.fixture
-def differences(icc1, icc2):
-    return icc1.compare(icc2).details
+    difference = fixture.compare(MissingFile('/nonexisting', fixture))
 
- at skip_unless_tools_exist('cd-iccdump')
-def test_diff(differences):
-    expected_diff = open(data('icc_expected_diff')).read()
-    assert differences[0].unified_diff == expected_diff
+    output_html(difference, print_func=print)
+    output_text(difference, print_func=print)
 
- at skip_unless_tools_exist('cd-iccdump')
-def test_compare_non_existing(monkeypatch, icc1):
-    monkeypatch.setattr(Config(), 'new_file', True)
-    difference = icc1.compare(MissingFile('/nonexisting', icc1))
     assert difference.source2 == '/nonexisting'
-    assert len(difference.details) > 0
-
+    assert not has_details or len(difference.details) > 0
+    assert not has_null_source or difference.details[-1].source2 == '/dev/null'
diff --git a/tests/comparators/utils.py b/tests/comparators/utils/tools.py
similarity index 52%
rename from tests/comparators/utils.py
rename to tests/comparators/utils/tools.py
index 5a0930f..4bed1d3 100644
--- a/tests/comparators/utils.py
+++ b/tests/comparators/utils/tools.py
@@ -2,7 +2,8 @@
 #
 # diffoscope: in-depth comparison of files, archives, and directories
 #
-# Copyright © 2015 Jérémy Bobbio <lunar at debian.org>
+# Copyright © 2015      Jérémy Bobbio <lunar at debian.org>
+#             2016-2017 Mattia Rizzolo <mattia at debian.org>
 #
 # diffoscope is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,24 +18,11 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
 
-import os
-import re
 import pytest
-import diffoscope
 
 from distutils.spawn import find_executable
 from distutils.version import LooseVersion
 
-from diffoscope.config import Config
-from diffoscope.presenters.html import output_html
-from diffoscope.presenters.text import output_text
-from diffoscope.comparators.binary import FilesystemFile
-from diffoscope.comparators.missing_file import MissingFile
-from diffoscope.comparators.utils.specialize import specialize
-
-re_diff_line_numbers = re.compile(r"(^|\n)@@ -(\d+),(\d+) \+(\d+),(\d+) @@(?=\n|$)")
-
-
 def tools_missing(*required):
     return not required or any(find_executable(x) is None for x in required)
 
@@ -53,31 +41,3 @@ def skip_unless_tool_is_at_least(tool, actual_ver, min_ver, vcls=LooseVersion):
         vcls(str(actual_ver)) < vcls(str(min_ver)),
         reason="requires {} >= {} ({} detected)".format(tool, min_ver, actual_ver)
     )
-
-def load_fixture(filename):
-    return pytest.fixture(
-        lambda: specialize(FilesystemFile(filename))
-    )
-
-def data(filename):
-    return os.path.join(
-        os.path.dirname(os.path.dirname(__file__)),
-        'data',
-        filename,
-    )
-
-def assert_non_existing(monkeypatch, fixture, has_null_source=True, has_details=True):
-    monkeypatch.setattr(Config(), 'new_file', True)
-    assert Config().new_file, "didnt get patched"
-
-    difference = fixture.compare(MissingFile('/nonexisting', fixture))
-
-    output_html(difference, print_func=print)
-    output_text(difference, print_func=print)
-
-    assert difference.source2 == '/nonexisting'
-    assert not has_details or len(difference.details) > 0
-    assert not has_null_source or difference.details[-1].source2 == '/dev/null'
-
-def diff_ignore_line_numbers(diff):
-    return re_diff_line_numbers.sub(r"\1@@ -XX,XX +XX,XX @@", diff)

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


More information about the diffoscope mailing list