diff options
author | Ben McGinnes <[email protected]> | 2018-08-18 10:29:14 +0000 |
---|---|---|
committer | Ben McGinnes <[email protected]> | 2018-08-18 10:29:14 +0000 |
commit | 5facba45c83f7daaacc49e66306e13a35aeb74be (patch) | |
tree | baf659036cb95f3d5c75babdc242a4629c864616 /lang/python/tests/t-encrypt-large.py | |
parent | Python bindings examples: PEP8 conpliance (diff) | |
download | gpgme-5facba45c83f7daaacc49e66306e13a35aeb74be.tar.gz gpgme-5facba45c83f7daaacc49e66306e13a35aeb74be.zip |
Python bindings tests: Near PEP8 compliance
* PEP8 compliance for the vast majoeity of the tests.
Diffstat (limited to 'lang/python/tests/t-encrypt-large.py')
-rwxr-xr-x | lang/python/tests/t-encrypt-large.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lang/python/tests/t-encrypt-large.py b/lang/python/tests/t-encrypt-large.py index 56460851..18576ac3 100755 --- a/lang/python/tests/t-encrypt-large.py +++ b/lang/python/tests/t-encrypt-large.py @@ -18,13 +18,14 @@ # License along with this program; if not, see <http://www.gnu.org/licenses/>. from __future__ import absolute_import, print_function, unicode_literals -del absolute_import, print_function, unicode_literals import sys import random import gpg import support +del absolute_import, print_function, unicode_literals + if len(sys.argv) == 2: nbytes = int(sys.argv[1]) else: @@ -33,6 +34,8 @@ else: c = gpg.Context() ntoread = nbytes + + def read_cb(amount): global ntoread chunk = ntoread if ntoread < amount else amount @@ -41,12 +44,16 @@ def read_cb(amount): assert chunk >= 0 return bytes(bytearray(random.randrange(256) for i in range(chunk))) + nwritten = 0 + + def write_cb(data): global nwritten nwritten += len(data) return len(data) + source = gpg.Data(cbs=(read_cb, None, None, lambda: None)) sink = gpg.Data(cbs=(None, write_cb, None, lambda: None)) @@ -61,5 +68,5 @@ assert not result.invalid_recipients, \ assert ntoread == 0 if support.verbose: - sys.stderr.write( - "plaintext={} bytes, ciphertext={} bytes\n".format(nbytes, nwritten)) + sys.stderr.write("plaintext={} bytes, ciphertext={} bytes\n".format( + nbytes, nwritten)) |