summaryrefslogtreecommitdiff
path: root/tests/unix
diff options
context:
space:
mode:
authormicroDev <70126934+microDev1@users.noreply.github.com>2021-03-15 19:27:36 +0530
committermicroDev <70126934+microDev1@users.noreply.github.com>2021-03-15 19:27:36 +0530
commita52eb88031620a81521b937f2a0651dbac2bb350 (patch)
tree017cbf8f686b252241182ef61ce48e8457aa1577 /tests/unix
parent090b6ba42fcdfbb16844f77892087f91aa6ea201 (diff)
run code formatting script
Diffstat (limited to 'tests/unix')
-rw-r--r--tests/unix/extra_coverage.py51
-rw-r--r--tests/unix/ffi_callback.py7
-rw-r--r--tests/unix/ffi_float.py13
-rw-r--r--tests/unix/ffi_float2.py7
4 files changed, 44 insertions, 34 deletions
diff --git a/tests/unix/extra_coverage.py b/tests/unix/extra_coverage.py
index 13721f1f4..e31eece77 100644
--- a/tests/unix/extra_coverage.py
+++ b/tests/unix/extra_coverage.py
@@ -13,33 +13,33 @@ data = extra_coverage()
print(data[0], data[1])
print(hash(data[0]))
print(hash(data[1]))
-print(hash(bytes(data[0], 'utf8')))
-print(hash(str(data[1], 'utf8')))
+print(hash(bytes(data[0], "utf8")))
+print(hash(str(data[1], "utf8")))
# test streams
-stream = data[2] # has set_error and set_buf. Write always returns error
-stream.set_error(uerrno.EAGAIN) # non-blocking error
-print(stream.read()) # read all encounters non-blocking error
-print(stream.read(1)) # read 1 byte encounters non-blocking error
-print(stream.readline()) # readline encounters non-blocking error
-print(stream.readinto(bytearray(10))) # readinto encounters non-blocking error
-print(stream.write(b'1')) # write encounters non-blocking error
-print(stream.write1(b'1')) # write1 encounters non-blocking error
-stream.set_buf(b'123')
-print(stream.read(4)) # read encounters non-blocking error after successful reads
-stream.set_buf(b'123')
-print(stream.read1(4)) # read1 encounters non-blocking error after successful reads
-stream.set_buf(b'123')
-print(stream.readline(4)) # readline encounters non-blocking error after successful reads
+stream = data[2] # has set_error and set_buf. Write always returns error
+stream.set_error(uerrno.EAGAIN) # non-blocking error
+print(stream.read()) # read all encounters non-blocking error
+print(stream.read(1)) # read 1 byte encounters non-blocking error
+print(stream.readline()) # readline encounters non-blocking error
+print(stream.readinto(bytearray(10))) # readinto encounters non-blocking error
+print(stream.write(b"1")) # write encounters non-blocking error
+print(stream.write1(b"1")) # write1 encounters non-blocking error
+stream.set_buf(b"123")
+print(stream.read(4)) # read encounters non-blocking error after successful reads
+stream.set_buf(b"123")
+print(stream.read1(4)) # read1 encounters non-blocking error after successful reads
+stream.set_buf(b"123")
+print(stream.readline(4)) # readline encounters non-blocking error after successful reads
try:
- print(stream.ioctl(0, 0)) # ioctl encounters non-blocking error; raises OSError
+ print(stream.ioctl(0, 0)) # ioctl encounters non-blocking error; raises OSError
except OSError:
- print('OSError')
+ print("OSError")
stream.set_error(0)
-print(stream.ioctl(0, bytearray(10))) # successful ioctl call
+print(stream.ioctl(0, bytearray(10))) # successful ioctl call
-stream2 = data[3] # is textio
-print(stream2.read(1)) # read 1 byte encounters non-blocking error with textio stream
+stream2 = data[3] # is textio
+print(stream2.read(1)) # read 1 byte encounters non-blocking error with textio stream
# test BufferedWriter with stream errors
stream.set_error(uerrno.EAGAIN)
@@ -52,23 +52,28 @@ import frzmpy1
# test import of frozen packages with __init__.py
import frzstr_pkg1
+
print(frzstr_pkg1.x)
import frzmpy_pkg1
+
print(frzmpy_pkg1.x)
# test import of frozen packages without __init__.py
from frzstr_pkg2.mod import Foo
+
print(Foo.x)
from frzmpy_pkg2.mod import Foo
+
print(Foo.x)
# test raising exception in frozen script
try:
import frzmpy2
except ZeroDivisionError:
- print('ZeroDivisionError')
+ print("ZeroDivisionError")
# test loading a resource from a frozen string
import uio
-buf = uio.resource_stream('frzstr_pkg2', 'mod.py')
+
+buf = uio.resource_stream("frzstr_pkg2", "mod.py")
print(buf.read(21))
diff --git a/tests/unix/ffi_callback.py b/tests/unix/ffi_callback.py
index 23b058bce..21bfccf25 100644
--- a/tests/unix/ffi_callback.py
+++ b/tests/unix/ffi_callback.py
@@ -15,16 +15,19 @@ def ffi_open(names):
err = e
raise err
-libc = ffi_open(('libc.so', 'libc.so.0', 'libc.so.6', 'libc.dylib'))
+
+libc = ffi_open(("libc.so", "libc.so.0", "libc.so.6", "libc.dylib"))
qsort = libc.func("v", "qsort", "piip")
+
def cmp(pa, pb):
a = ffi.as_bytearray(pa, 1)
b = ffi.as_bytearray(pb, 1)
- #print("cmp:", a, b)
+ # print("cmp:", a, b)
return a[0] - b[0]
+
cmp_c = ffi.callback("i", cmp, "pp")
s = bytearray(b"foobar")
diff --git a/tests/unix/ffi_float.py b/tests/unix/ffi_float.py
index c92a39bcd..b12bce968 100644
--- a/tests/unix/ffi_float.py
+++ b/tests/unix/ffi_float.py
@@ -16,17 +16,18 @@ def ffi_open(names):
err = e
raise err
-libc = ffi_open(('libc.so', 'libc.so.0', 'libc.so.6', 'libc.dylib'))
+
+libc = ffi_open(("libc.so", "libc.so.0", "libc.so.6", "libc.dylib"))
strtof = libc.func("f", "strtof", "sp")
-print('%.6f' % strtof('1.23', None))
+print("%.6f" % strtof("1.23", None))
strtod = libc.func("d", "strtod", "sp")
-print('%.6f' % strtod('1.23', None))
+print("%.6f" % strtod("1.23", None))
# test passing double and float args
-libm = ffi_open(('libm.so', 'libm.so.6', 'libc.so.0', 'libc.so.6', 'libc.dylib'))
-tgamma = libm.func('d', 'tgamma', 'd')
+libm = ffi_open(("libm.so", "libm.so.6", "libc.so.0", "libc.so.6", "libc.dylib"))
+tgamma = libm.func("d", "tgamma", "d")
for fun in (tgamma,):
for val in (0.5, 1, 1.0, 1.5, 4, 4.0):
- print('%.6f' % fun(val))
+ print("%.6f" % fun(val))
diff --git a/tests/unix/ffi_float2.py b/tests/unix/ffi_float2.py
index 721eb4d19..bbed69666 100644
--- a/tests/unix/ffi_float2.py
+++ b/tests/unix/ffi_float2.py
@@ -16,16 +16,17 @@ def ffi_open(names):
err = e
raise err
-libm = ffi_open(('libm.so', 'libm.so.6', 'libc.so.0', 'libc.so.6', 'libc.dylib'))
+
+libm = ffi_open(("libm.so", "libm.so.6", "libc.so.0", "libc.so.6", "libc.dylib"))
# Some libc's implement tgammaf as header macro with tgamma(), so don't assume
# it'll be in library.
try:
- tgammaf = libm.func('f', 'tgammaf', 'f')
+ tgammaf = libm.func("f", "tgammaf", "f")
except OSError:
print("SKIP")
raise SystemExit
for fun in (tgammaf,):
for val in (0.5, 1, 1.0, 1.5, 4, 4.0):
- print('%.6f' % fun(val))
+ print("%.6f" % fun(val))