Skip to content

Commit 6979164

Browse files
committed
Update docs, make test more resilient across different GnuPG versions.
1 parent f0c7298 commit 6979164

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

docs/index.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ To decrypt a message, use the following approach::
769769

770770
If you want to decrypt data in a file (or file-like object), use::
771771

772-
>>> decrypted_data = gpg.decrypt_file(stream) # e.g. after stream = open(filename, "rb")
772+
>>> decrypted_data = gpg.decrypt_file(stream) # e.g. after stream = open(filename, 'rb')
773773

774774
These methods both return an object such that ``str(decrypted_data)`` gives the
775775
decrypted data in a non-binary format. If decryption succeeded, the returned object's
@@ -845,6 +845,24 @@ you can test the trust level against known values as in the following example::
845845
.. versionadded:: 0.3.1
846846
The ``trust_level`` and ``trust_text`` attributes were added.
847847

848+
849+
Finding the recipients for an encrypted message
850+
-----------------------------------------------
851+
852+
Sometimes, it's desirable to find the recipients for an encrypted message, without
853+
actually performing decryption. You can do this using the :meth:`get_recipients` or
854+
:meth:`get_recipients_file` methods:
855+
856+
>>> ids = gpg.get_recipients(data)
857+
858+
or, with a file or file-like object:
859+
860+
>>> ids = gpg.get_recipients_file(stream) # e.g. after stream = open(filename, 'rb')
861+
862+
.. versionadded:: 0.4.8
863+
The ``get_recipients`` and ``get_recipients_file`` methods were added.
864+
865+
848866
Signing and Verification
849867
========================
850868

test_gnupg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,8 +1240,8 @@ def test_no_such_key(self):
12401240
self.remove_all_existing_keys()
12411241
decrypted = gpg.decrypt(str(encrypted), passphrase='bbrown')
12421242
self.assertFalse(decrypted.ok)
1243-
expected = 'decryption failed' if gpg.version == (2, 3, 1) else 'no secret key'
1244-
self.assertEqual(decrypted.status, expected)
1243+
expected = {'decryption failed', 'no secret key', 'no data was provided'}
1244+
self.assertIn(decrypted.status, expected)
12451245
finally:
12461246
logger.debug("test_no_such_key ends")
12471247

0 commit comments

Comments
 (0)