diff --git a/tests/test_deploy.py b/tests/test_deploy.py index d6c32d89..6ca8a40c 100755 --- a/tests/test_deploy.py +++ b/tests/test_deploy.py @@ -11,16 +11,11 @@ from unittest import mock import git import fdroidserver -from .testcommon import TmpCwd, mkdtemp +from .testcommon import TmpCwd, mkdtemp, VerboseFalseOptions basedir = Path(__file__).parent -class Options: - quiet = False - verbose = False - - class DeployTest(unittest.TestCase): '''fdroidserver/deploy.py''' @@ -122,7 +117,7 @@ class DeployTest(unittest.TestCase): fdroidserver.deploy.config['rclone'] = True fdroidserver.deploy.config['rclone_config'] = 'test-local-config' fdroidserver.deploy.config['path_to_custom_rclone_config'] = str(rclone_file) - fdroidserver.common.options = Options + fdroidserver.common.options = VerboseFalseOptions # write out destination path destination = Path('test_bucket_folder/fdroid') @@ -166,7 +161,7 @@ class DeployTest(unittest.TestCase): fdroidserver.deploy.config['rclone'] = True fdroidserver.deploy.config['rclone_config'] = 'test-local-config' fdroidserver.deploy.config['path_to_custom_rclone_config'] = str(rclone_file) - fdroidserver.common.options = Options + fdroidserver.common.options = VerboseFalseOptions # write out destination path destination = Path('test_bucket_folder/fdroid') diff --git a/tests/test_import_subcommand.py b/tests/test_import_subcommand.py index 4483841d..ba2f133a 100755 --- a/tests/test_import_subcommand.py +++ b/tests/test_import_subcommand.py @@ -13,7 +13,7 @@ import git import requests import yaml -from .testcommon import TmpCwd, mkdtemp +from .testcommon import TmpCwd, mkdtemp, VerboseFalseOptions import fdroidserver import fdroidserver.import_subcommand @@ -91,7 +91,7 @@ class ImportTest(unittest.TestCase): print('Skipping ImportTest!') return - fdroidserver.common.options = type('Options', (), {'verbose': False}) + fdroidserver.common.options = VerboseFalseOptions app = fdroidserver.import_subcommand.get_app_from_url(url) fdroidserver.import_subcommand.clone_to_tmp_dir(app) self.assertEqual(app.RepoType, 'git') diff --git a/tests/test_publish.py b/tests/test_publish.py index df7ed72c..6ca3b116 100755 --- a/tests/test_publish.py +++ b/tests/test_publish.py @@ -24,7 +24,7 @@ from fdroidserver import common from fdroidserver import metadata from fdroidserver import signatures from fdroidserver.exception import FDroidException -from .testcommon import mkdtemp +from .testcommon import mkdtemp, VerboseFalseOptions basedir = pathlib.Path(__file__).parent @@ -247,12 +247,9 @@ class PublishTest(unittest.TestCase): self.assertEqual(publish.config['keytool'], data['keytool']) def test_sign_then_implant_signature(self): - class Options: - verbose = False - os.chdir(self.testdir) - common.options = Options + common.options = VerboseFalseOptions config = common.read_config() if 'apksigner' not in config: self.skipTest('SKIPPING test_sign_then_implant_signature, apksigner not installed!') diff --git a/tests/test_vcs.py b/tests/test_vcs.py index 9a210d60..93fcd6a7 100755 --- a/tests/test_vcs.py +++ b/tests/test_vcs.py @@ -7,7 +7,7 @@ from git import Repo import fdroidserver.common import fdroidserver.metadata -from .testcommon import mkdtemp +from .testcommon import mkdtemp, VerboseFalseOptions class VCSTest(unittest.TestCase): @@ -54,7 +54,7 @@ class VCSTest(unittest.TestCase): vcs, build_dir = fdroidserver.common.setup_vcs(app) # force an init of the repo, the remote head error only occurs on the second gotorevision call - fdroidserver.common.options = type('Options', (), {'verbose': False}) + fdroidserver.common.options = VerboseFalseOptions vcs.gotorevision(build.commit) fdroidserver.common.prepare_source( vcs, diff --git a/tests/testcommon.py b/tests/testcommon.py index e1031da6..ec095508 100644 --- a/tests/testcommon.py +++ b/tests/testcommon.py @@ -27,6 +27,10 @@ from pathlib import Path GP_FINGERPRINT = 'B7C2EEFD8DAC7806AF67DFCD92EB18126BC08312A7F2D6F3862E46013C7A6135' +class VerboseFalseOptions: + verbose = False + + class TmpCwd: """Context-manager for temporarily changing the current working directory."""