aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/tests/t-data.py
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2016-10-31 13:42:26 +0000
committerJustus Winter <[email protected]>2016-10-31 14:42:35 +0000
commit20dc37a0e7e1531b0e568a6ec29b1c2d18de59c3 (patch)
tree27b9415a448303e9741cc2ee416c9a7598560755 /lang/python/tests/t-data.py
parentpython: Improve constants module. (diff)
downloadgpgme-20dc37a0e7e1531b0e568a6ec29b1c2d18de59c3.tar.gz
gpgme-20dc37a0e7e1531b0e568a6ec29b1c2d18de59c3.zip
python: Import the topmost module in tests and examples.
* examples/verifydetails.py: Only import the topmost module 'gpg' and update the code accordingly. * tests/support.py: Likewise. * tests/t-callbacks.py: Likewise. * tests/t-data.py: Likewise. * tests/t-decrypt-verify.py: Likewise. * tests/t-decrypt.py: Likewise. * tests/t-edit.py: Likewise. * tests/t-encrypt-large.py: Likewise. * tests/t-encrypt-sign.py: Likewise. * tests/t-encrypt-sym.py: Likewise. * tests/t-encrypt.py: Likewise. * tests/t-export.py: Likewise. * tests/t-file-name.py: Likewise. * tests/t-import.py: Likewise. * tests/t-keylist.py: Likewise. * tests/t-sig-notation.py: Likewise. * tests/t-sign.py: Likewise. * tests/t-signers.py: Likewise. * tests/t-trustlist.py: Likewise. * tests/t-verify.py: Likewise. * tests/t-wait.py: Likewise. * tests/t-wrapper.py: Likewise. Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'lang/python/tests/t-data.py')
-rwxr-xr-xlang/python/tests/t-data.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/lang/python/tests/t-data.py b/lang/python/tests/t-data.py
index 16b2a7b5..d1facd40 100755
--- a/lang/python/tests/t-data.py
+++ b/lang/python/tests/t-data.py
@@ -23,9 +23,9 @@ del absolute_import, print_function, unicode_literals
import io
import os
import tempfile
-from gpg import core
+import gpg
-data = core.Data('Hello world!')
+data = gpg.Data('Hello world!')
assert data.read() == b'Hello world!'
assert data.read() == b''
@@ -33,29 +33,29 @@ data.seek(0, os.SEEK_SET)
assert data.read() == b'Hello world!'
assert data.read() == b''
-data = core.Data(b'Hello world!')
+data = gpg.Data(b'Hello world!')
assert data.read() == b'Hello world!'
-data = core.Data(b'Hello world!', copy=False)
+data = gpg.Data(b'Hello world!', copy=False)
assert data.read() == b'Hello world!'
-data = core.Data()
+data = gpg.Data()
data.write('Hello world!')
data.seek(0, os.SEEK_SET)
assert data.read() == b'Hello world!'
-data = core.Data()
+data = gpg.Data()
data.write(b'Hello world!')
data.seek(0, os.SEEK_SET)
assert data.read() == b'Hello world!'
binjunk = bytes(range(256))
-data = core.Data()
+data = gpg.Data()
data.write(binjunk)
data.seek(0, os.SEEK_SET)
assert data.read() == binjunk
-data = core.Data()
+data = gpg.Data()
data.set_file_name("foobar")
assert data.get_file_name() == "foobar"
@@ -66,26 +66,26 @@ with tempfile.NamedTemporaryFile() as tmp:
tmp.seek(0)
# Open using name.
- data = core.Data(file=tmp.name)
+ data = gpg.Data(file=tmp.name)
assert data.read() == binjunk
# Open using name, without copying.
if False:
# delayed reads are not yet supported
- data = core.Data(file=tmp.name, copy=False)
+ data = gpg.Data(file=tmp.name, copy=False)
assert data.read() == binjunk
# Open using stream.
tmp.seek(0)
- data = core.Data(file=tmp)
+ data = gpg.Data(file=tmp)
assert data.read() == binjunk
# Open using stream, offset, and length.
- data = core.Data(file=tmp, offset=0, length=42)
+ data = gpg.Data(file=tmp, offset=0, length=42)
assert data.read() == binjunk[:42]
# Open using name, offset, and length.
- data = core.Data(file=tmp.name, offset=23, length=42)
+ data = gpg.Data(file=tmp.name, offset=23, length=42)
assert data.read() == binjunk[23:23+42]
# Test callbacks.
@@ -112,7 +112,7 @@ class DataObject(object):
do = DataObject()
cookie = object()
-data = core.Data(cbs=(do.read, do.write, do.seek, do.release, cookie))
+data = gpg.Data(cbs=(do.read, do.write, do.seek, do.release, cookie))
data.write('Hello world!')
data.seek(0, os.SEEK_SET)
assert data.read() == b'Hello world!'
@@ -121,7 +121,7 @@ assert do.released
# Again, without the cookie.
do = DataObject()
-data = core.Data(cbs=(do.read, do.write, do.seek, do.release))
+data = gpg.Data(cbs=(do.read, do.write, do.seek, do.release))
data.write('Hello world!')
data.seek(0, os.SEEK_SET)
assert data.read() == b'Hello world!'