Exemple #1
0
import uio
import usys

try:
    uio.resource_stream
except AttributeError:
    print("SKIP")
    raise SystemExit

buf = uio.resource_stream("data", "file2")
print(buf.read())

# resource_stream(None, ...) look ups from current dir, hence sys.path[0] hack
buf = uio.resource_stream(None, usys.path[0] + "/data/file2")
print(buf.read())
stream.set_error(uerrno.EAGAIN)
buf = uio.BufferedWriter(stream, 8)
print(buf.write(bytearray(16)))

# test basic import of frozen scripts
import frzstr1
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')

# test loading a resource from a frozen string
import uio
buf = uio.resource_stream('frzstr_pkg2', 'mod.py')
print(buf.read(21))
Exemple #3
0
stream.set_error(uerrno.EAGAIN)
buf = uio.BufferedWriter(stream, 8)
print(buf.write(bytearray(16)))

# test basic import of frozen scripts
import frzstr1
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')

# test loading a resource from a frozen string
import uio
buf = uio.resource_stream('frzstr_pkg2', 'mod.py')
print(buf.read(21))
print(frzstr_pkg1.__file__, frzstr_pkg1.x)
import frzmpy_pkg1

print(frzmpy_pkg1.__file__, 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")

# test loading a resource from a frozen string
import uio

buf = uio.resource_stream("frzstr_pkg2", "mod.py")
print(buf.read(21))

# test for MP_QSTR_NULL regression
from frzqstr import returns_NULL

print(returns_NULL())