Fix doctest for GPG.import_key().
parent
434a650799
commit
eb93fd48de
23
src/gnupg.py
23
src/gnupg.py
|
@ -818,15 +818,15 @@ use_agent: %s
|
||||||
Import the key_data into our keyring.
|
Import the key_data into our keyring.
|
||||||
|
|
||||||
>>> import shutil
|
>>> import shutil
|
||||||
>>> shutil.rmtree("keys")
|
>>> shutil.rmtree("doctests")
|
||||||
>>> gpg = GPG(homedir="keys")
|
>>> gpg = gnupg.GPG(homedir="doctests")
|
||||||
>>> input = gpg.gen_key_input()
|
>>> inpt = gpg.gen_key_input()
|
||||||
>>> result = gpg.gen_key(input)
|
>>> key1 = gpg.gen_key(inpt)
|
||||||
>>> print1 = result.fingerprint
|
>>> print1 = str(key1.fingerprint)
|
||||||
>>> result = gpg.gen_key(input)
|
|
||||||
>>> print2 = result.fingerprint
|
|
||||||
>>> pubkey1 = gpg.export_keys(print1)
|
>>> pubkey1 = gpg.export_keys(print1)
|
||||||
>>> seckey1 = gpg.export_keys(print1,secret=True)
|
>>> seckey1 = gpg.export_keys(print1,secret=True)
|
||||||
|
>>> key2 = gpg.gen_key(inpt)
|
||||||
|
>>> print2 = key2.fingerprint
|
||||||
>>> seckeys = gpg.list_keys(secret=True)
|
>>> seckeys = gpg.list_keys(secret=True)
|
||||||
>>> pubkeys = gpg.list_keys()
|
>>> pubkeys = gpg.list_keys()
|
||||||
>>> assert print1 in seckeys.fingerprints
|
>>> assert print1 in seckeys.fingerprints
|
||||||
|
@ -837,14 +837,8 @@ use_agent: %s
|
||||||
'ok'
|
'ok'
|
||||||
>>> str(gpg.delete_keys(print1))
|
>>> str(gpg.delete_keys(print1))
|
||||||
'ok'
|
'ok'
|
||||||
>>> str(gpg.delete_keys("nosuchkey"))
|
|
||||||
'No such key'
|
|
||||||
>>> seckeys = gpg.list_keys(secret=True)
|
|
||||||
>>> pubkeys = gpg.list_keys()
|
>>> pubkeys = gpg.list_keys()
|
||||||
>>> assert not print1 in seckeys.fingerprints
|
|
||||||
>>> assert not print1 in pubkeys.fingerprints
|
>>> assert not print1 in pubkeys.fingerprints
|
||||||
>>> result = gpg.import_keys('foo')
|
|
||||||
>>> assert not result
|
|
||||||
>>> result = gpg.import_keys(pubkey1)
|
>>> result = gpg.import_keys(pubkey1)
|
||||||
>>> pubkeys = gpg.list_keys()
|
>>> pubkeys = gpg.list_keys()
|
||||||
>>> seckeys = gpg.list_keys(secret=True)
|
>>> seckeys = gpg.list_keys(secret=True)
|
||||||
|
@ -853,10 +847,7 @@ use_agent: %s
|
||||||
>>> result = gpg.import_keys(seckey1)
|
>>> result = gpg.import_keys(seckey1)
|
||||||
>>> assert result
|
>>> assert result
|
||||||
>>> seckeys = gpg.list_keys(secret=True)
|
>>> seckeys = gpg.list_keys(secret=True)
|
||||||
>>> pubkeys = gpg.list_keys()
|
|
||||||
>>> assert print1 in seckeys.fingerprints
|
>>> assert print1 in seckeys.fingerprints
|
||||||
>>> assert print1 in pubkeys.fingerprints
|
|
||||||
>>> assert print2 in pubkeys.fingerprints
|
|
||||||
"""
|
"""
|
||||||
## xxx need way to validate that key_data is actually a valid GPG key
|
## xxx need way to validate that key_data is actually a valid GPG key
|
||||||
## it might be possible to use --list-packets and parse the output
|
## it might be possible to use --list-packets and parse the output
|
||||||
|
|
Loading…
Reference in New Issue