From 79285c4c17bc915dc0340d8ba5444a453c9dd861 Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Fri, 13 Mar 2015 03:45:20 +0000 Subject: [PATCH] Add @doktorstick's example code for reproducing #93 as a unittest. * ADD regression test for #93. --- gnupg/test/test_gnupg.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/gnupg/test/test_gnupg.py b/gnupg/test/test_gnupg.py index d6bbb6e..484fdc2 100755 --- a/gnupg/test/test_gnupg.py +++ b/gnupg/test/test_gnupg.py @@ -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',