From 3cf9aedc92b6c65d2cb34037e52b9a299637d03b Mon Sep 17 00:00:00 2001 From: Tobias Mueller Date: Tue, 22 Aug 2017 17:48:25 +0200 Subject: python: Default whence argument for Data() to SEEK_SET. * lang/python/gpgme.i: copied signature from gpgme.h and defaulted the value to SEEK_SET. * lang/python/tests/t-data.py: Added a test for no second argument -- Having to import the os package when wanting to read a Data object is a slight annoyance. With SWIG, we can define default parameters. This change defaults the whence argument to SEEK_SET which is how StringIO and BytesIO behave. Signed-off-by: Tobias Mueller --- lang/python/tests/t-data.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lang/python/tests/t-data.py') diff --git a/lang/python/tests/t-data.py b/lang/python/tests/t-data.py index 33013193..5cf074c5 100755 --- a/lang/python/tests/t-data.py +++ b/lang/python/tests/t-data.py @@ -51,6 +51,12 @@ data.write(b'Hello world!') data.seek(0, os.SEEK_SET) assert data.read() == b'Hello world!' +data = gpg.Data() +data.write(b'Hello world!') +# We expect the second argument to default to SEEK_SET +data.seek(0) +assert data.read() == b'Hello world!' + binjunk = bytes(range(256)) data = gpg.Data() data.write(binjunk) -- cgit v1.2.3