Add @doktorstick's example code for reproducing #93 as a unittest.

* ADD regression test for #93.
fix/93-encrypt-to-stream
Isis Lovecruft 2015-03-13 03:45:20 +00:00
parent 6d1890389c
commit 79285c4c17
No known key found for this signature in database
GPG Key ID: 18C16EC5F9F1D673
1 changed files with 24 additions and 1 deletions

View File

@ -1192,6 +1192,28 @@ know, maybe you shouldn't be doing it in the first place.
self.assertTrue(encrypted.ok)
self.assertGreater(len(encrypted.data), 0)
def test_encryption_with_output(self):
"""Test that ``encrypt('foo', ..., output='/foo/bar/baz')`` is successful."""
message_filename = os.path.join(_files, 'cypherpunk_manifesto')
with open (message_filename, 'rb') as f:
data = f.read()
output = os.path.join(self.gpg.homedir, 'test-encryption-with-output.gpg')
kwargs = dict(passphrase='speedtest',
symmetric=True,
cipher_algo='AES256',
encrypt=False,
output=output)
encrypted = self.gpg.encrypt(data, None, **kwargs)
self.assertTrue(encrypted.ok)
self.assertGreater(len(encrypted.data), 0)
self.assertTrue(os.path.isfile(output))
# Check the contents:
with open(output, 'rb') as fh:
encrypted_message = fh.read()
self.assertTrue(b"-----BEGIN PGP MESSAGE-----" in encrypted_message)
suites = { 'parsers': set(['test_parsers_fix_unsafe',
'test_parsers_fix_unsafe_semicolon',
@ -1245,7 +1267,8 @@ suites = { 'parsers': set(['test_parsers_fix_unsafe',
'test_file_encryption_and_decryption',
'test_encryption_to_filename',
'test_encryption_to_filehandle',
'test_encryption_from_filehandle',]),
'test_encryption_from_filehandle',
'test_encryption_with_output',]),
'listkeys': set(['test_list_keys_after_generation']),
'keyrings': set(['test_public_keyring',
'test_secret_keyring',