aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/tests/t-encrypt.py
diff options
context:
space:
mode:
authorTobias Mueller <[email protected]>2016-12-02 22:37:27 +0000
committerJustus Winter <[email protected]>2016-12-05 11:44:20 +0000
commit05896c210f7fa9ce7b97784a75e49dc4489e9252 (patch)
tree10e20776c4e885ab14ae115181ff88a5ff997321 /lang/python/tests/t-encrypt.py
parentpython: Define a macro for wrapping fragile result objects. (diff)
downloadgpgme-05896c210f7fa9ce7b97784a75e49dc4489e9252.tar.gz
gpgme-05896c210f7fa9ce7b97784a75e49dc4489e9252.zip
python: Try to be more helpful when given a string to encrypt().
* lang/python/helpers.c (_gpg_obj2gpgme_data_t): Extended error message. * lang/python/tests/t-encrypt.py: Test for "encode" in error message. -- The motivation is to help the user when encrypting fails. I claim that it is not obvious to not being able to encrypt a string directly. To nudge the user into encoding it to bytes, the error message is a bit extended. Signed-off-by: Tobias Mueller <[email protected]>
Diffstat (limited to 'lang/python/tests/t-encrypt.py')
-rwxr-xr-xlang/python/tests/t-encrypt.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/lang/python/tests/t-encrypt.py b/lang/python/tests/t-encrypt.py
index 0c0ca357..3cbe8f2f 100755
--- a/lang/python/tests/t-encrypt.py
+++ b/lang/python/tests/t-encrypt.py
@@ -62,3 +62,18 @@ with gpg.Context(armor=True) as c:
assert support.sign_only.endswith(e.recipients[0].fpr)
else:
assert False, "Expected an InvalidRecipients error, got none"
+
+
+
+ try:
+ # People might be tempted to provide strings.
+ # We should raise something useful.
+ ciphertext, _, _ = c.encrypt("Hallo Leute\n",
+ recipients=keys,
+ sign=False,
+ always_trust=True)
+ except TypeError as e:
+ # This test is a bit fragile, because the message
+ # may very well change. So if the behaviour will change
+ # this test can easily be deleted.
+ assert "encode" in str(e)