From be1c3d34761e5af6807a9af5d00d6328e9d4aa7e Mon Sep 17 00:00:00 2001 From: Saeed Rasooli Date: Sun, 29 Dec 2024 14:31:21 +0330 Subject: [PATCH] tests: add SKIP_MISSING env and some minor cleanup --- tests/g_aard2_slob_test.py | 4 ---- tests/g_appledict_bin_test.py | 9 +++++++++ tests/g_ebook_epub2_test.py | 4 ---- tests/g_kobo_test.py | 10 +++++++++- tests/slob_test.py | 3 --- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/tests/g_aard2_slob_test.py b/tests/g_aard2_slob_test.py index e9dd8f0a0..19021d945 100644 --- a/tests/g_aard2_slob_test.py +++ b/tests/g_aard2_slob_test.py @@ -3,8 +3,6 @@ from glossary_v2_test import TestGlossaryBase -skip_module = False - class TestGlossarySlob(TestGlossaryBase): def __init__(self, *args, **kwargs): @@ -20,8 +18,6 @@ def __init__(self, *args, **kwargs): ) def setUp(self): - if skip_module: - self.skipTest("module is skipped") TestGlossaryBase.setUp(self) def test_convert_txt_slob_1(self): diff --git a/tests/g_appledict_bin_test.py b/tests/g_appledict_bin_test.py index 5d2aa00ca..1fc98a4bf 100644 --- a/tests/g_appledict_bin_test.py +++ b/tests/g_appledict_bin_test.py @@ -1,3 +1,4 @@ +import os import sys import unittest from os.path import abspath, dirname, join @@ -11,6 +12,14 @@ class TestGlossaryAppleDictBin(TestGlossaryBase): + def setUp(self): + if os.getenv("SKIP_MISSING"): + try: + import biplist # noqa: F401 + except ImportError: + self.skipTest("skipping module due to missing dependency: biplist") + TestGlossaryBase.setUp(self) + def __init__(self, *args, **kwargs): TestGlossaryBase.__init__(self, *args, **kwargs) diff --git a/tests/g_ebook_epub2_test.py b/tests/g_ebook_epub2_test.py index 1369b05bd..242dedb37 100644 --- a/tests/g_ebook_epub2_test.py +++ b/tests/g_ebook_epub2_test.py @@ -10,8 +10,6 @@ from pyglossary.glossary_v2 import ConvertArgs, Glossary -skip_module = False - class TestGlossaryEPUB2(TestGlossaryBase): def __init__(self, *args, **kwargs): @@ -27,8 +25,6 @@ def __init__(self, *args, **kwargs): ) def setUp(self): - if skip_module: - self.skipTest("module is skipped") TestGlossaryBase.setUp(self) def remove_toc_uid(self, data): diff --git a/tests/g_kobo_test.py b/tests/g_kobo_test.py index 8c171c996..345459a96 100644 --- a/tests/g_kobo_test.py +++ b/tests/g_kobo_test.py @@ -1,11 +1,19 @@ import gzip +import os import unittest -import marisa_trie # noqa: F401, to ensure it's installed from glossary_v2_test import TestGlossaryBase class TestGlossaryKobo(TestGlossaryBase): + def setUp(self): + if os.getenv("SKIP_MISSING"): + try: + import marisa_trie # noqa: F401 + except ImportError: + self.skipTest("skipping module due to missing dependency: marisa_trie") + TestGlossaryBase.setUp(self) + def __init__(self, *args, **kwargs): TestGlossaryBase.__init__(self, *args, **kwargs) # self.dataFileCRC32.update({}) diff --git a/tests/slob_test.py b/tests/slob_test.py index f0f8dc017..5033521ce 100644 --- a/tests/slob_test.py +++ b/tests/slob_test.py @@ -76,9 +76,6 @@ def set_tag_value(filename: str, name: str, value: str) -> None: class BaseTest(unittest.TestCase): def setUp(self): - # if skip_module: - # self.skipTest("module is skipped") - self.tmpdir = tempfile.TemporaryDirectory(prefix="test") self._writers = []