From e2f427ea5c0347fb5995ed2a9bc00f780c212c70 Mon Sep 17 00:00:00 2001 From: Paul Mulders Date: Wed, 23 Jun 2021 16:56:00 +0200 Subject: [PATCH 1/2] Port tests/test_05_actions.py to pytest-order --- requirements-test.txt | 2 +- tests/test_05_actions.py | 48 ++++++++++++++++++++-------------------- tox.ini | 2 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/requirements-test.txt b/requirements-test.txt index cb561765..a71b3cc7 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,7 +1,7 @@ -r requirements.txt pytest pytest-cov -pytest-ordering +pytest-order flake8 pep8-naming # NOTE: gpg is not here on purpose currently diff --git a/tests/test_05_actions.py b/tests/test_05_actions.py index 9724798a..5a6adb02 100644 --- a/tests/test_05_actions.py +++ b/tests/test_05_actions.py @@ -251,7 +251,7 @@ def gpg_verify_key(self, key): assert vres - @pytest.mark.run('first') + @pytest.mark.order(1) @pytest.mark.parametrize('alg,size', pkeyspecs) def test_gen_key(self, alg, size): # create a primary key with a UID @@ -275,7 +275,7 @@ def test_gen_key(self, alg, size): # try to verify with GPG self.gpg_verify_key(key) - @pytest.mark.run(after='test_gen_key') + @pytest.mark.order(after='test_gen_key') @pytest.mark.parametrize('pkspec,skspec', itertools.product(pkeyspecs, skeyspecs), ids=['{}-{}-{}'.format(pk[0].name, sk[0].name, sk[1]) for pk, sk in itertools.product(pkeyspecs, skeyspecs)]) @@ -315,7 +315,7 @@ def test_add_subkey(self, pkspec, skspec): # try to verify with GPG self.gpg_verify_key(key) - @pytest.mark.run(after='test_add_subkey') + @pytest.mark.order(after='test_add_subkey') @pytest.mark.parametrize('pkspec', pkeyspecs, ids=[str(a) for a, s in pkeyspecs]) def test_add_altuid(self, pkspec): if pkspec not in self.keys: @@ -356,7 +356,7 @@ def test_add_altuid(self, pkspec): # try to verify with GPG self.gpg_verify_key(key) - @pytest.mark.run(after='test_add_altuid') + @pytest.mark.order(after='test_add_altuid') @pytest.mark.parametrize('pkspec', pkeyspecs, ids=[str(a) for a, s in pkeyspecs]) def test_add_photo(self, pkspec, userphoto): if pkspec not in self.keys: @@ -373,7 +373,7 @@ def test_add_photo(self, pkspec, userphoto): # try to verify with GPG self.gpg_verify_key(key) - @pytest.mark.run(after='test_add_photo') + @pytest.mark.order(after='test_add_photo') @pytest.mark.parametrize('pkspec', pkeyspecs, ids=[str(a) for a, s in pkeyspecs]) def test_revoke_altuid(self, pkspec): if pkspec not in self.keys: @@ -386,7 +386,7 @@ def test_revoke_altuid(self, pkspec): revsig = key.revoke(altuid) altuid |= revsig - @pytest.mark.run(after='test_remove_altuid') + @pytest.mark.order(after='test_remove_altuid') @pytest.mark.parametrize('pkspec', pkeyspecs, ids=[str(a) for a, s in pkeyspecs]) def test_remove_altuid(self, pkspec): if pkspec not in self.keys: @@ -398,7 +398,7 @@ def test_remove_altuid(self, pkspec): assert not key.get_uid('T. Keyerson') - @pytest.mark.run(after='test_remove_altuid') + @pytest.mark.order(after='test_remove_altuid') @pytest.mark.parametrize('pkspec', pkeyspecs, ids=[str(a) for a, s in pkeyspecs]) def test_add_revocation_key(self, pkspec): if pkspec not in self.keys: @@ -416,7 +416,7 @@ def test_add_revocation_key(self, pkspec): # try to verify with GPG self.gpg_verify_key(key) - @pytest.mark.run(after='test_add_revocation_key') + @pytest.mark.order(after='test_add_revocation_key') @pytest.mark.parametrize('pkspec', pkeyspecs, ids=[str(a) for a, s in pkeyspecs]) def test_protect(self, pkspec): if pkspec not in self.keys: @@ -436,7 +436,7 @@ def test_protect(self, pkspec): # try to verify with GPG self.gpg_verify_key(key) - @pytest.mark.run(after='test_protect') + @pytest.mark.order(after='test_protect') @pytest.mark.parametrize('pkspec', pkeyspecs, ids=[str(a) for a, s in pkeyspecs]) def test_unlock(self, pkspec): if pkspec not in self.keys: @@ -451,7 +451,7 @@ def test_unlock(self, pkspec): with key.unlock('There Are Many Like It, But This Key Is Mine') as _unlocked: assert _unlocked.is_unlocked - @pytest.mark.run(after='test_unlock') + @pytest.mark.order(after='test_unlock') @pytest.mark.parametrize('pkspec', pkeyspecs, ids=[str(a) for a, s in pkeyspecs]) def test_change_passphrase(self, pkspec): if pkspec not in self.keys: @@ -463,7 +463,7 @@ def test_change_passphrase(self, pkspec): with key.unlock('There Are Many Like It, But This Key Is Mine') as ukey: ukey.protect('This Password Has Been Changed', ukey._key.keymaterial.s2k.encalg, ukey._key.keymaterial.s2k.halg) - @pytest.mark.run(after='test_change_passphrase') + @pytest.mark.order(after='test_change_passphrase') @pytest.mark.parametrize('pkspec', pkeyspecs, ids=[str(a) for a, s in pkeyspecs]) def test_unlock2(self, pkspec): if pkspec not in self.keys: @@ -475,7 +475,7 @@ def test_unlock2(self, pkspec): with key.unlock('This Password Has Been Changed') as ukey: assert ukey.is_unlocked - @pytest.mark.run(after='test_unlock2') + @pytest.mark.order(after='test_unlock2') @pytest.mark.parametrize('pkspec', pkeyspecs, ids=[str(a) for a, s in pkeyspecs]) def test_pub_from_sec(self, pkspec): if pkspec not in self.keys: @@ -497,7 +497,7 @@ def test_pub_from_sec(self, pkspec): # try to verify with GPG self.gpg_verify_key(pub) - @pytest.mark.run(after='test_pub_from_spec') + @pytest.mark.order(after='test_pub_from_spec') @pytest.mark.parametrize('pkspec,skspec', itertools.product(pkeyspecs, skeyspecs), ids=['{}-{}-{}'.format(pk[0].name, sk[0].name, sk[1]) for pk, sk in @@ -534,7 +534,7 @@ def test_revoke_subkey(self, pkspec, skspec): # try to verify with GPG self.gpg_verify_key(key) - @pytest.mark.run(after='test_revoke_subkey') + @pytest.mark.order(after='test_revoke_subkey') @pytest.mark.parametrize('pkspec', pkeyspecs, ids=[str(a) for a, s in pkeyspecs]) def test_revoke_key(self, pkspec): if pkspec not in self.keys: @@ -558,7 +558,7 @@ def test_revoke_key(self, pkspec): # try to verify with GPG self.gpg_verify_key(key) - @pytest.mark.run(after='test_revoke_key') + @pytest.mark.order(after='test_revoke_key') def test_revoke_key_with_revoker(self): pytest.skip("not implemented yet") @@ -705,7 +705,7 @@ def test_sign_string(self, targette_sec, targette_pub, string): # verify with GnuPG self.gpg_verify(string, sig, targette_pub) - @pytest.mark.run(after='test_sign_string') + @pytest.mark.order(after='test_sign_string') def test_verify_string(self, targette_pub, string): # verify the signature on the string sig = self.sigs['string'] @@ -728,7 +728,7 @@ def test_sign_message(self, targette_sec, targette_pub, message): # verify with GnuPG self.gpg_verify(message, pubkey=targette_pub) - @pytest.mark.run(after='test_sign_message') + @pytest.mark.order(after='test_sign_message') def test_verify_message(self, targette_pub, message): # test verifying a signed message sv = targette_pub.verify(message) @@ -751,7 +751,7 @@ def test_sign_ctmessage(self, targette_sec, targette_pub, ctmessage): # verify with GnuPG self.gpg_verify(ctmessage, pubkey=targette_pub) - @pytest.mark.run(after='test_sign_ctmessage') + @pytest.mark.order(after='test_sign_ctmessage') def test_verify_ctmessage(self, targette_pub, ctmessage): # test verifying a signed cleartext message sv = targette_pub.verify(ctmessage) @@ -769,7 +769,7 @@ def test_sign_timestamp(self, sec): self.sigs[(sec._key.fingerprint.keyid, 'timestamp')] = sig - @pytest.mark.run(after='test_sign_timestamp') + @pytest.mark.order(after='test_sign_timestamp') @pytest.mark.parametrize('pub', pubkeys, ids=[os.path.basename(f) for f in sorted(glob.glob('tests/testdata/keys/*.pub.asc'))]) def test_verify_timestamp(self, pub): @@ -794,7 +794,7 @@ def test_sign_standalone(self, sec): assert sig.notation == {"cheese status": "standing alone"} self.sigs[(sec._key.fingerprint.keyid, 'standalone')] = sig - @pytest.mark.run(after='test_sign_standalone') + @pytest.mark.order(after='test_sign_standalone') @pytest.mark.parametrize('pub', pubkeys, ids=[os.path.basename(f) for f in sorted(glob.glob('tests/testdata/keys/*.pub.asc'))]) def test_verify_standalone(self, pub): @@ -852,7 +852,7 @@ def test_certify_uid(self, sec, abe): assert sig.exportable assert ({sec.fingerprint.keyid} | set(sec.subkeys)) & userid.signers - @pytest.mark.run(after='test_certify_uid') + @pytest.mark.order(after='test_certify_uid') @pytest.mark.parametrize('pub', pubkeys, ids=[os.path.basename(f) for f in sorted(glob.glob('tests/testdata/keys/*.pub.asc'))]) def test_verify_userid(self, pub, abe): @@ -869,7 +869,7 @@ def test_certify_photo(self, sec, abe): userphoto = abe.userattributes[0] userphoto |= sec.certify(userphoto) - @pytest.mark.run(after='test_certify_photo') + @pytest.mark.order(after='test_certify_photo') @pytest.mark.parametrize('pub', pubkeys, ids=[os.path.basename(f) for f in sorted(glob.glob('tests/testdata/keys/*.pub.asc'))]) def test_verify_photo(self, pub, abe): @@ -922,7 +922,7 @@ def test_encrypt_message(self, pub, cipher): emsg = pub.encrypt(msg, cipher=cipher) self.msgs[(pub.fingerprint, cipher)] = emsg - @pytest.mark.run(after='test_encrypt_message') + @pytest.mark.order(after='test_encrypt_message') @pytest.mark.parametrize('sf,cipher', itertools.product(sorted(glob.glob('tests/testdata/keys/*.sec.asc')), sorted(SymmetricKeyAlgorithm))) def test_decrypt_message(self, sf, cipher): @@ -946,7 +946,7 @@ def test_decrypt_message(self, sf, cipher): if gpg: assert self.gpg_decrypt(emsg, sec).decode('utf-8') == dmsg.message - @pytest.mark.run(after='test_encrypt_message') + @pytest.mark.order(after='test_encrypt_message') @pytest.mark.parametrize('sf,cipher', itertools.product(sorted(glob.glob('tests/testdata/keys/*.sec.asc')), sorted(SymmetricKeyAlgorithm))) def test_sign_encrypted_message(self, sf, cipher): diff --git a/tox.ini b/tox.ini index 9df8f304..cc65c0be 100644 --- a/tox.ini +++ b/tox.ini @@ -23,7 +23,7 @@ deps = six>=1.9.0 pytest pytest-cov - pytest-ordering + pytest-order install_command = pip install {opts} --no-cache-dir {packages} commands = From f0c7ce247d601c9ef6b03fba453624498ef739ec Mon Sep 17 00:00:00 2001 From: James Morris Date: Fri, 25 Jun 2021 15:32:23 -0400 Subject: [PATCH 2/2] Use a compatible version of pytest-order --- requirements-test.txt | 2 +- tox.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements-test.txt b/requirements-test.txt index a71b3cc7..f4bb491a 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,7 +1,7 @@ -r requirements.txt pytest pytest-cov -pytest-order +pytest-order<1.0 flake8 pep8-naming # NOTE: gpg is not here on purpose currently diff --git a/tox.ini b/tox.ini index cc65c0be..cc616e86 100644 --- a/tox.ini +++ b/tox.ini @@ -23,7 +23,7 @@ deps = six>=1.9.0 pytest pytest-cov - pytest-order + pytest-order<1.0 install_command = pip install {opts} --no-cache-dir {packages} commands =