aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/tests/t-quick-key-creation.py
diff options
context:
space:
mode:
authorBen McGinnes <[email protected]>2018-08-18 10:29:14 +0000
committerBen McGinnes <[email protected]>2018-08-18 10:29:14 +0000
commit5facba45c83f7daaacc49e66306e13a35aeb74be (patch)
treebaf659036cb95f3d5c75babdc242a4629c864616 /lang/python/tests/t-quick-key-creation.py
parentPython bindings examples: PEP8 conpliance (diff)
downloadgpgme-5facba45c83f7daaacc49e66306e13a35aeb74be.tar.gz
gpgme-5facba45c83f7daaacc49e66306e13a35aeb74be.zip
Python bindings tests: Near PEP8 compliance
* PEP8 compliance for the vast majoeity of the tests.
Diffstat (limited to 'lang/python/tests/t-quick-key-creation.py')
-rwxr-xr-xlang/python/tests/t-quick-key-creation.py28
1 files changed, 18 insertions, 10 deletions
diff --git a/lang/python/tests/t-quick-key-creation.py b/lang/python/tests/t-quick-key-creation.py
index 8b7372e7..47209288 100755
--- a/lang/python/tests/t-quick-key-creation.py
+++ b/lang/python/tests/t-quick-key-creation.py
@@ -18,7 +18,6 @@
# License along with this program; if not, see <http://www.gnu.org/licenses/>.
from __future__ import absolute_import, print_function, unicode_literals
-del absolute_import, print_function, unicode_literals
import gpg
import itertools
@@ -27,6 +26,8 @@ import time
import support
support.assert_gpg_version((2, 1, 2))
+del absolute_import, print_function, unicode_literals
+
alpha = "Alpha <[email protected]>"
with support.EphemeralContext() as ctx:
@@ -51,14 +52,16 @@ with support.EphemeralContext() as ctx:
res2 = ctx.create_key(alpha, force=True)
assert res.fpr != res2.fpr
-
# From here on, we use one context, and create unique UIDs
uid_counter = 0
+
+
def make_uid():
global uid_counter
uid_counter += 1
return "user{0}@invalid.example.org".format(uid_counter)
+
with support.EphemeralContext() as ctx:
# Check gpg.constants.create.NOEXPIRE...
res = ctx.create_key(make_uid(), expires=False)
@@ -77,10 +80,8 @@ with support.EphemeralContext() as ctx:
"Primary keys expiration time is off"
# Check capabilities
- for sign, encrypt, certify, authenticate in itertools.product([False, True],
- [False, True],
- [False, True],
- [False, True]):
+ for sign, encrypt, certify, authenticate in itertools.
+ product([False, True], [False, True], [False, True], [False, True]):
# Filter some out
if not (sign or encrypt or certify or authenticate):
# This triggers the default capabilities tested before.
@@ -89,9 +90,13 @@ with support.EphemeralContext() as ctx:
# The primary key always certifies.
continue
- res = ctx.create_key(make_uid(), algorithm="rsa",
- sign=sign, encrypt=encrypt, certify=certify,
- authenticate=authenticate)
+ res = ctx.create_key(
+ make_uid(),
+ algorithm="rsa",
+ sign=sign,
+ encrypt=encrypt,
+ certify=certify,
+ authenticate=authenticate)
key = ctx.get_key(res.fpr, secret=True)
assert key.fpr == res.fpr
assert len(key.subkeys) == 1, \
@@ -125,13 +130,16 @@ with support.EphemeralContext() as ctx:
recipient = make_uid()
passphrase = "streng geheim"
res = ctx.create_key(recipient, passphrase=passphrase)
- ciphertext, _, _ = ctx.encrypt(b"hello there", recipients=[ctx.get_key(res.fpr)])
+ ciphertext, _, _ = ctx.encrypt(
+ b"hello there", recipients=[ctx.get_key(res.fpr)])
cb_called = False
+
def cb(*args):
global cb_called
cb_called = True
return passphrase
+
ctx.pinentry_mode = gpg.constants.PINENTRY_MODE_LOOPBACK
ctx.set_passphrase_cb(cb)