aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/tests/t-quick-subkey-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-subkey-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-subkey-creation.py')
-rwxr-xr-xlang/python/tests/t-quick-subkey-creation.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/lang/python/tests/t-quick-subkey-creation.py b/lang/python/tests/t-quick-subkey-creation.py
index ad4f35c6..30424c19 100755
--- a/lang/python/tests/t-quick-subkey-creation.py
+++ b/lang/python/tests/t-quick-subkey-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
@@ -26,6 +25,8 @@ import time
import support
+del absolute_import, print_function, unicode_literals
+
alpha = "Alpha <[email protected]>"
bravo = "Bravo <[email protected]>"
@@ -59,16 +60,15 @@ with support.EphemeralContext() as ctx:
"subkeys expiration time is off"
# Check capabilities
- for sign, encrypt, authenticate in itertools.product([False, True],
- [False, True],
- [False, True]):
+ for sign, encrypt, authenticate in itertools.
+ product([False, True], [False, True], [False, True]):
# Filter some out
if not (sign or encrypt or authenticate):
# This triggers the default capabilities tested before.
continue
- res = ctx.create_subkey(key, sign=sign, encrypt=encrypt,
- authenticate=authenticate)
+ res = ctx.create_subkey(
+ key, sign=sign, encrypt=encrypt, authenticate=authenticate)
subkey = get_subkey(res.fpr)
assert sign == subkey.can_sign
assert encrypt == subkey.can_encrypt
@@ -92,18 +92,21 @@ with support.EphemeralContext() as ctx:
# so that we have a key with just one encryption subkey.
bravo_res = ctx.create_key(bravo, certify=True)
bravo_key = ctx.get_key(bravo_res.fpr)
- assert len(bravo_key.subkeys) == 1, "Expected one primary key and no subkeys"
+ assert len(
+ bravo_key.subkeys) == 1, "Expected one primary key and no subkeys"
passphrase = "streng geheim"
res = ctx.create_subkey(bravo_key, passphrase=passphrase)
- ciphertext, _, _ = ctx.encrypt(b"hello there",
- recipients=[ctx.get_key(bravo_res.fpr)])
+ ciphertext, _, _ = ctx.encrypt(
+ b"hello there", recipients=[ctx.get_key(bravo_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)