python: Fix a couple of syntax errors.

* lang/python/tests/t-keylist-from-data.py: Add missing line
continuation.
* lang/python/tests/t-keylist.py: Ditto.
* lang/python/tests/t-quick-key-creation.py: Ditto.
* lang/python/tests/t-quick-subkey-creation.py: Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2018-09-20 17:30:48 +02:00
parent dcdabf5f2e
commit 6878126b6f
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
4 changed files with 92 additions and 84 deletions

View File

@ -162,18 +162,18 @@ def check_global(key, uids, n_subkeys):
assert key.can_sign, "Key unexpectedly unusable for signing" assert key.can_sign, "Key unexpectedly unusable for signing"
assert key.can_certify, "Key unexpectedly unusable for certifications" assert key.can_certify, "Key unexpectedly unusable for certifications"
assert not key.secret, "Key unexpectedly secret" assert not key.secret, "Key unexpectedly secret"
assert not key.protocol != gpg.constants.protocol. assert not key.protocol != gpg.constants.protocol.OpenPGP, \
OpenPGP, "Key has unexpected protocol: {}".format(key.protocol) "Key has unexpected protocol: {}".format(key.protocol)
assert not key.issuer_serial, assert not key.issuer_serial, \
"Key unexpectedly carries issuer serial: {}".format(key.issuer_serial) "Key unexpectedly carries issuer serial: {}".format(key.issuer_serial)
assert not key.issuer_name, assert not key.issuer_name, \
"Key unexpectedly carries issuer name: {}".format(key.issuer_name) "Key unexpectedly carries issuer name: {}".format(key.issuer_name)
assert not key.chain_id, assert not key.chain_id, \
"Key unexpectedly carries chain ID: {}".format(key.chain_id) "Key unexpectedly carries chain ID: {}".format(key.chain_id)
assert key.owner_trust == gpg.constants.validity.UNKNOWN, assert key.owner_trust == gpg.constants.validity.UNKNOWN, \
"Key has unexpected owner trust: {}".format(key.owner_trust) "Key has unexpected owner trust: {}".format(key.owner_trust)
assert len(key.subkeys) - 1 == n_subkeys, assert len(key.subkeys) - 1 == n_subkeys, \
"Key `{}' has unexpected number of subkeys".format(uids[0][0]) "Key `{}' has unexpected number of subkeys".format(uids[0][0])
def check_subkey(fpr, which, subkey): def check_subkey(fpr, which, subkey):
@ -183,49 +183,51 @@ def check_subkey(fpr, which, subkey):
assert not subkey.invalid, which + " key unexpectedly invalid" assert not subkey.invalid, which + " key unexpectedly invalid"
if which == "Primary": if which == "Primary":
assert not subkey.can_encrypt, assert not subkey.can_encrypt, \
which + " key unexpectedly usable for encryption" which + " key unexpectedly usable for encryption"
assert subkey.can_sign, assert subkey.can_sign, \
which + " key unexpectedly unusable for signing" which + " key unexpectedly unusable for signing"
assert subkey.can_certify, assert subkey.can_certify, \
which + " key unexpectedly unusable for certifications" which + " key unexpectedly unusable for certifications"
else: else:
assert subkey.can_encrypt, assert subkey.can_encrypt, \
which + " key unexpectedly unusable for encryption" which + " key unexpectedly unusable for encryption"
assert not subkey.can_sign, assert not subkey.can_sign, \
which + " key unexpectedly usable for signing" which + " key unexpectedly usable for signing"
assert not subkey.can_certify, assert not subkey.can_certify, \
which + " key unexpectedly usable for certifications" which + " key unexpectedly usable for certifications"
assert not subkey.secret, which + " key unexpectedly secret" assert not subkey.secret, which + " key unexpectedly secret"
assert not subkey.is_cardkey, "Public key marked as card key" assert not subkey.is_cardkey, "Public key marked as card key"
assert not subkey.card_number, "Public key with card number set" assert not subkey.card_number, "Public key with card number set"
assert not subkey.pubkey_algo != assert not subkey.pubkey_algo != \
(gpg.constants.pk.DSA if which == "Primary" else gpg.constants.pk.ELG_E), (gpg.constants.pk.DSA if which == "Primary"
which + " key has unexpected public key algo: {}".format(subkey. else gpg.constants.pk.ELG_E), \
pubkey_algo) which + " key has unexpected public key algo: {}".format(subkey.
assert subkey.length == 1024, pubkey_algo)
which + " key has unexpected length: {}".format(subkey.length) assert subkey.length == 1024, \
assert fpr.endswith(subkey.keyid), which + " key has unexpected length: {}".format(subkey.length)
which + " key has unexpected key ID: {}".format(subkey.keyid) assert fpr.endswith(subkey.keyid), \
assert which == "Secondary" or subkey.fpr == fpr, which + " key has unexpected key ID: {}".format(subkey.keyid)
which + " key has unexpected fingerprint: {}".format(subkey.fpr) assert which == "Secondary" or subkey.fpr == fpr, \
assert not subkey.expires, which + " key has unexpected fingerprint: {}".format(subkey.fpr)
which + " key unexpectedly expires: {}".format(subkey.expires) assert not subkey.expires, \
which + " key unexpectedly expires: {}".format(subkey.expires)
def check_uid(which, ref, uid): def check_uid(which, ref, uid):
assert not uid.revoked, which + " user ID unexpectedly revoked" assert not uid.revoked, which + " user ID unexpectedly revoked"
assert not uid.invalid, which + " user ID unexpectedly invalid" assert not uid.invalid, which + " user ID unexpectedly invalid"
assert uid.validity == gpg.constants.validity.UNKNOWN, assert uid.validity == gpg.constants.validity.UNKNOWN, \
which + " user ID has unexpected validity: {}".format(uid.validity) which + " user ID has unexpected validity: {}".format(uid.validity)
assert not uid.signatures, which + " user ID unexpectedly signed" assert not uid.signatures, which + " user ID unexpectedly signed"
assert uid.name == ref[0], assert uid.name == ref[0], \
"Unexpected name in {} user ID: {!r}".format(which.lower(), uid.name) "Unexpected name in {} user ID: {!r}".format(which.lower(), uid.name)
assert uid.comment == ref[1], assert uid.comment == ref[1], \
"Unexpected comment in {} user ID: {!r}".format(which.lower(), uid.comment) "Unexpected comment in {} user ID: {!r}".format(which.lower(),
assert uid.email == ref[2], uid.comment)
"Unexpected email in {} user ID: {!r}".format(which.lower(), uid.email) assert uid.email == ref[2], \
"Unexpected email in {} user ID: {!r}".format(which.lower(), uid.email)
# Export all the data from our keyring... # Export all the data from our keyring...

View File

@ -162,25 +162,25 @@ def check_global(key, uids, n_subkeys):
assert key.can_sign, "Key unexpectedly unusable for signing" assert key.can_sign, "Key unexpectedly unusable for signing"
assert key.can_certify, "Key unexpectedly unusable for certifications" assert key.can_certify, "Key unexpectedly unusable for certifications"
assert not key.secret, "Key unexpectedly secret" assert not key.secret, "Key unexpectedly secret"
assert not key.protocol != gpg.constants.protocol.OpenPGP, assert not key.protocol != gpg.constants.protocol.OpenPGP, \
"Key has unexpected protocol: {}".format(key.protocol) "Key has unexpected protocol: {}".format(key.protocol)
assert not key.issuer_serial, assert not key.issuer_serial, \
"Key unexpectedly carries issuer serial: {}".format(key.issuer_serial) "Key unexpectedly carries issuer serial: {}".format(key.issuer_serial)
assert not key.issuer_name, assert not key.issuer_name, \
"Key unexpectedly carries issuer name: {}".format(key.issuer_name) "Key unexpectedly carries issuer name: {}".format(key.issuer_name)
assert not key.chain_id, assert not key.chain_id, \
"Key unexpectedly carries chain ID: {}".format(key.chain_id) "Key unexpectedly carries chain ID: {}".format(key.chain_id)
# Only key Alfa is trusted # Only key Alfa is trusted
assert key.uids[0].name == 'Alfa Test' or assert (key.uids[0].name == 'Alfa Test'
key.owner_trust == gpg.constants.validity.UNKNOWN, or key.owner_trust == gpg.constants.validity.UNKNOWN), \
"Key has unexpected owner trust: {}".format(key.owner_trust) "Key has unexpected owner trust: {}".format(key.owner_trust)
assert key.uids[0].name != 'Alfa Test' or key.owner_trust == gpg.constants. assert (key.uids[0].name != 'Alfa Test'
validity.ULTIMATE, "Key has unexpected owner trust: {}". or key.owner_trust == gpg.constants.validity.ULTIMATE), \
format(key.owner_trust) "Key has unexpected owner trust: {}".format(key.owner_trust)
assert len(key.subkeys) - 1 == n_subkeys, assert len(key.subkeys) - 1 == n_subkeys, \
"Key `{}' has unexpected number of subkeys".format(uids[0][0]) "Key `{}' has unexpected number of subkeys".format(uids[0][0])
def check_subkey(fpr, which, subkey): def check_subkey(fpr, which, subkey):
@ -207,18 +207,19 @@ def check_subkey(fpr, which, subkey):
assert not subkey.secret, which + " key unexpectedly secret" assert not subkey.secret, which + " key unexpectedly secret"
assert not subkey.is_cardkey, "Public key marked as card key" assert not subkey.is_cardkey, "Public key marked as card key"
assert not subkey.card_number, "Public key with card number set" assert not subkey.card_number, "Public key with card number set"
assert not subkey.pubkey_algo != assert not subkey.pubkey_algo != \
(gpg.constants.pk.DSA if which == "Primary" else gpg.constants.pk.ELG_E), (gpg.constants.pk.DSA if which == "Primary"
which + " key has unexpected public key algo: {}".format(subkey. else gpg.constants.pk.ELG_E), \
which + " key has unexpected public key algo: {}".format(subkey.
pubkey_algo) pubkey_algo)
assert subkey.length == 1024, assert subkey.length == 1024, \
which + " key has unexpected length: {}".format(subkey.length) which + " key has unexpected length: {}".format(subkey.length)
assert fpr.endswith(subkey.keyid), assert fpr.endswith(subkey.keyid), \
which + " key has unexpected key ID: {}".format(subkey.keyid) which + " key has unexpected key ID: {}".format(subkey.keyid)
assert which == "Secondary" or subkey.fpr == fpr, assert which == "Secondary" or subkey.fpr == fpr, \
which + " key has unexpected fingerprint: {}".format(subkey.fpr) which + " key has unexpected fingerprint: {}".format(subkey.fpr)
assert not subkey.expires, assert not subkey.expires, \
which + " key unexpectedly expires: {}".format(subkey.expires) which + " key unexpectedly expires: {}".format(subkey.expires)
def check_uid(which, ref, uid): def check_uid(which, ref, uid):
@ -227,16 +228,16 @@ def check_uid(which, ref, uid):
assert uid.validity == (gpg.constants.validity.UNKNOWN assert uid.validity == (gpg.constants.validity.UNKNOWN
if uid.name.split()[0] if uid.name.split()[0]
not in {'Alfa', 'Alpha', 'Alice'} else not in {'Alfa', 'Alpha', 'Alice'} else
gpg.constants.validity.ULTIMATE), gpg.constants.validity.ULTIMATE), \
which + " user ID has unexpectedly validity: {}".format(uid.validity) which + " user ID has unexpectedly validity: {}".format(uid.validity)
assert not uid.signatures, which + " user ID unexpectedly signed" assert not uid.signatures, which + " user ID unexpectedly signed"
assert uid.name == ref[0], assert uid.name == ref[0], \
"Unexpected name in {} user ID: {!r}".format(which.lower(), uid.name) "Unexpected name in {} user ID: {!r}".format(which.lower(), uid.name)
assert uid.comment == ref[1], assert uid.comment == ref[1], \
"Unexpected comment in {} user ID: {!r}".format(which.lower(), "Unexpected comment in {} user ID: {!r}".\
uid.comment) format(which.lower(), uid.comment)
assert uid.email == ref[2], assert uid.email == ref[2], \
"Unexpected email in {} user ID: {!r}".format(which.lower(), uid.email) "Unexpected email in {} user ID: {!r}".format(which.lower(), uid.email)
i = 0 i = 0

View File

@ -80,8 +80,11 @@ with support.EphemeralContext() as ctx:
"Primary keys expiration time is off" "Primary keys expiration time is off"
# Check capabilities # Check capabilities
for sign, encrypt, certify, authenticate in itertools. for sign, encrypt, certify, authenticate \
product([False, True], [False, True], [False, True], [False, True]): in itertools.product([False, True],
[False, True],
[False, True],
[False, True]):
# Filter some out # Filter some out
if not (sign or encrypt or certify or authenticate): if not (sign or encrypt or certify or authenticate):
# This triggers the default capabilities tested before. # This triggers the default capabilities tested before.

View File

@ -60,8 +60,10 @@ with support.EphemeralContext() as ctx:
"subkeys expiration time is off" "subkeys expiration time is off"
# Check capabilities # Check capabilities
for sign, encrypt, authenticate in itertools. for sign, encrypt, authenticate \
product([False, True], [False, True], [False, True]): in itertools.product([False, True],
[False, True],
[False, True]):
# Filter some out # Filter some out
if not (sign or encrypt or authenticate): if not (sign or encrypt or authenticate):
# This triggers the default capabilities tested before. # This triggers the default capabilities tested before.