pgp: use always_trust for encrypting to pgp-mime-text in doctest.
authorW. Trevor King <wking@tremily.us>
Sun, 21 Oct 2012 19:37:31 +0000 (15:37 -0400)
committerW. Trevor King <wking@tremily.us>
Sun, 21 Oct 2012 20:01:07 +0000 (16:01 -0400)
This avoids the abiguously described "General error":

  S: OK GPGME-Tool 1.3.3-git73b439a ready
  C: ARMOR true
  S: OK
  C: RECIPIENT pgp-mime@invalid.com
  S: S RECIPIENT B2EDBE0E771A4B8708DD16A7511AEDA64332B6E3
  S: OK
  C: # descriptors in flight: [3]
  C: INPUT FD
  S: OK
  C: # descriptors in flight: [6]
  C: OUTPUT FD
  S: OK
  C: ENCRYPT
  S: ERR 1 General error <Unspecified source>
  C: BYE
  S: OK closing connection

I have spend some time trying to track this one down in gpgme-tool,
but without success.

pgp_mime/pgp.py

index aefe77c65b1fc47ffa49d53c73eb5da7a121ab74..6bc2d11ca673fe5c5682c687f52480a34e9047a3 100644 (file)
@@ -147,7 +147,7 @@ def encrypt(message, recipients=None, **kwargs):
     >>> from pgp_mime.email import encodedMIMEText
     >>> message = encodedMIMEText('Hi\nBye')
     >>> message['To'] = 'pgp-mime-test <pgp-mime@invalid.com>'
     >>> from pgp_mime.email import encodedMIMEText
     >>> message = encodedMIMEText('Hi\nBye')
     >>> message['To'] = 'pgp-mime-test <pgp-mime@invalid.com>'
-    >>> encrypted = encrypt(message)
+    >>> encrypted = encrypt(message, always_trust=True)
     >>> encrypted.set_boundary('boundsep')
     >>> print(encrypted.as_string())  # doctest: +ELLIPSIS, +REPORT_UDIFF
     Content-Type: multipart/encrypted; protocol="application/pgp-encrypted"; micalg="pgp-sha1"; boundary="boundsep"
     >>> encrypted.set_boundary('boundsep')
     >>> print(encrypted.as_string())  # doctest: +ELLIPSIS, +REPORT_UDIFF
     Content-Type: multipart/encrypted; protocol="application/pgp-encrypted"; micalg="pgp-sha1"; boundary="boundsep"
@@ -386,7 +386,8 @@ def decrypt(message, **kwargs):
 
     >>> from pgp_mime.email import encodedMIMEText
     >>> message = encodedMIMEText('Hi\nBye')
 
     >>> from pgp_mime.email import encodedMIMEText
     >>> message = encodedMIMEText('Hi\nBye')
-    >>> encrypted = encrypt(message, recipients=['<pgp-mime@invalid.com>'])
+    >>> encrypted = encrypt(
+    ...     message, recipients=['<pgp-mime@invalid.com>'], always_trust=True)
     >>> decrypted = decrypt(encrypted)
     >>> print(decrypted.as_string().replace('\r\n', '\n'))
     ... # doctest: +ELLIPSIS, +REPORT_UDIFF
     >>> decrypted = decrypt(encrypted)
     >>> print(decrypted.as_string().replace('\r\n', '\n'))
     ... # doctest: +ELLIPSIS, +REPORT_UDIFF