From 21f919b14a9aeaa08aecbcdd41a530198315aad1 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Sun, 30 Aug 2020 16:24:10 +0200 Subject: tests: Use module-scope fixtures whenever possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Górny --- tests/test_openpgp.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'tests/test_openpgp.py') diff --git a/tests/test_openpgp.py b/tests/test_openpgp.py index ce62add..995c9da 100644 --- a/tests/test_openpgp.py +++ b/tests/test_openpgp.py @@ -37,11 +37,7 @@ from tests.keydata import ( OTHER_PUBLIC_KEY, OTHER_PUBLIC_KEY_UID, OTHER_PUBLIC_KEY_SIG, UNEXPIRE_SIG, ) -from tests.testutil import hkp_server - - -# workaround pyflakes -hkp_server = hkp_server +from tests.testutil import HKPServer VALID_PUBLIC_KEY = PUBLIC_KEY + UID + PUBLIC_KEY_SIG @@ -638,6 +634,22 @@ def test_recursive_manifest_loader_save_submanifest(tmp_path, privkey_env): assert m2.openpgp_signature is None +@pytest.fixture(scope='module') +def global_hkp_server(): + """A fixture that starts a single HKP server instance for tests""" + server = HKPServer() + server.start() + yield server + server.stop() + + +@pytest.fixture +def hkp_server(global_hkp_server): + """A fixture that resets the global HKP server with empty keys""" + global_hkp_server.keys.clear() + yield global_hkp_server + + COMBINED_PUBLIC_KEYS = OTHER_VALID_PUBLIC_KEY + VALID_PUBLIC_KEY -- cgit v1.2.3