AbstractBaseTest class for sharing setUp and tearDown in tests

This commit is contained in:
Hans-Christoph Steiner 2025-03-06 11:13:37 +01:00
parent f269232b96
commit 36007d50e5
2 changed files with 13 additions and 5 deletions

View File

@ -46,8 +46,8 @@ def _mock_common_module_options_instance():
fdroidserver.common.options.verbose = False fdroidserver.common.options.verbose = False
class CommonTest(unittest.TestCase): class SetUpTearDownMixin:
'''fdroidserver/common.py''' """A mixin with no tests in it for shared setUp and tearDown."""
def setUp(self): def setUp(self):
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
@ -77,6 +77,10 @@ class CommonTest(unittest.TestCase):
if os.path.exists(self.tmpdir): if os.path.exists(self.tmpdir):
shutil.rmtree(self.tmpdir) shutil.rmtree(self.tmpdir)
class CommonTest(SetUpTearDownMixin, unittest.TestCase):
'''fdroidserver/common.py'''
def test_yaml_1_2(self): def test_yaml_1_2(self):
"""Return a ruamel.yaml instance that supports YAML 1.2 """Return a ruamel.yaml instance that supports YAML 1.2
@ -3307,7 +3311,7 @@ class SignerExtractionTest(unittest.TestCase):
) )
class IgnoreApksignerV33Test(CommonTest): class IgnoreApksignerV33Test(SetUpTearDownMixin, unittest.TestCase):
"""apksigner v33 should be entirely ignored """apksigner v33 should be entirely ignored
https://gitlab.com/fdroid/fdroidserver/-/issues/1253 https://gitlab.com/fdroid/fdroidserver/-/issues/1253

View File

@ -19,8 +19,8 @@ from fdroidserver._yaml import config_dump
basedir = Path(__file__).parent basedir = Path(__file__).parent
class LintTest(unittest.TestCase): class SetUpTearDownMixin:
'''fdroidserver/lint.py''' """A base class with no test in it for shared setUp and tearDown."""
def setUp(self): def setUp(self):
os.chdir(basedir) os.chdir(basedir)
@ -33,6 +33,10 @@ class LintTest(unittest.TestCase):
def tearDown(self): def tearDown(self):
self._td.cleanup() self._td.cleanup()
class LintTest(SetUpTearDownMixin, unittest.TestCase):
'''fdroidserver/lint.py'''
def test_check_for_unsupported_metadata_files(self): def test_check_for_unsupported_metadata_files(self):
self.assertTrue(fdroidserver.lint.check_for_unsupported_metadata_files()) self.assertTrue(fdroidserver.lint.check_for_unsupported_metadata_files())