From eb93fd48deb8bc70c0b0326e0331ce43d5dccfd8 Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Mon, 27 May 2013 08:22:00 +0000 Subject: [PATCH] Fix doctest for GPG.import_key(). --- src/gnupg.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/gnupg.py b/src/gnupg.py index 26b7677..de38492 100644 --- a/src/gnupg.py +++ b/src/gnupg.py @@ -818,15 +818,15 @@ use_agent: %s Import the key_data into our keyring. >>> import shutil - >>> shutil.rmtree("keys") - >>> gpg = GPG(homedir="keys") - >>> input = gpg.gen_key_input() - >>> result = gpg.gen_key(input) - >>> print1 = result.fingerprint - >>> result = gpg.gen_key(input) - >>> print2 = result.fingerprint + >>> shutil.rmtree("doctests") + >>> gpg = gnupg.GPG(homedir="doctests") + >>> inpt = gpg.gen_key_input() + >>> key1 = gpg.gen_key(inpt) + >>> print1 = str(key1.fingerprint) >>> pubkey1 = gpg.export_keys(print1) >>> seckey1 = gpg.export_keys(print1,secret=True) + >>> key2 = gpg.gen_key(inpt) + >>> print2 = key2.fingerprint >>> seckeys = gpg.list_keys(secret=True) >>> pubkeys = gpg.list_keys() >>> assert print1 in seckeys.fingerprints @@ -837,14 +837,8 @@ use_agent: %s 'ok' >>> str(gpg.delete_keys(print1)) 'ok' - >>> str(gpg.delete_keys("nosuchkey")) - 'No such key' - >>> seckeys = gpg.list_keys(secret=True) >>> pubkeys = gpg.list_keys() - >>> assert not print1 in seckeys.fingerprints >>> assert not print1 in pubkeys.fingerprints - >>> result = gpg.import_keys('foo') - >>> assert not result >>> result = gpg.import_keys(pubkey1) >>> pubkeys = gpg.list_keys() >>> seckeys = gpg.list_keys(secret=True) @@ -853,10 +847,7 @@ use_agent: %s >>> result = gpg.import_keys(seckey1) >>> assert result >>> seckeys = gpg.list_keys(secret=True) - >>> pubkeys = gpg.list_keys() >>> 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 ## it might be possible to use --list-packets and parse the output