Skip to content

Commit

Permalink
Merge pull request #373 from justinkb/pytest-order-port
Browse files Browse the repository at this point in the history
Port tests/test_05_actions.py to pytest-order
  • Loading branch information
J-M0 authored Jun 28, 2021
2 parents f48cb60 + f0c7ce2 commit 5534d86
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-r requirements.txt
pytest
pytest-cov
pytest-ordering
pytest-order<1.0
flake8
pep8-naming
# NOTE: gpg is not here on purpose currently
48 changes: 24 additions & 24 deletions tests/test_05_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)])
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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")

Expand Down Expand Up @@ -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']
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ deps =
six>=1.9.0
pytest
pytest-cov
pytest-ordering
pytest-order<1.0

install_command = pip install {opts} --no-cache-dir {packages}
commands =
Expand Down

0 comments on commit 5534d86

Please sign in to comment.