Пример #1
0
import test_issue7_pyc  # brythontest2 in #7 => test_issue7_pyc
test_issue7_pyc.xxx = 123
assert test_issue7_pyc.xxx == 123
assert test_issue7_pyc.yyy() == 369

# Repeat tests for .pyc.js files deployed at a given path
print('Testing deployment of .pyc.js files')

# Install in sys.path the folder containing compiled py modules
pyc_path = __BRYTHON__.brython_path + '../tests/pycache'
sys.path[0] = pyc_path

# Optimize module imports
# i.e only send AJAX requests for .pyc.js files when processing this path
from _importlib import optimize_import_for_path
optimize_import_for_path(pyc_path, 'pyc.js')

try:
    from hello_pyc2 import *

    assert get_hello() == 'Hello from pyc2'
    assert world.get_world() == 'pyc2 world'

    import foo_pyc2
    assert foo_pyc2.get_foo() == 'foo from pyc2'
    assert foo_pyc2.get_bar() == 'bar from pyc2'

    # Assertions for issue #7
    import test_issue7_pyc2  # brythontest2 in #7 => test_issue7_pyc2
    test_issue7_pyc2.xxx = 123
    assert test_issue7_pyc2.xxx == 123
Пример #2
0
test_issue7_pyc.xxx = 123
assert test_issue7_pyc.xxx == 123
assert test_issue7_pyc.yyy() == 369


# Repeat tests for .pyc.js files deployed at a given path
print('Testing deployment of .pyc.js files')

# Install in sys.path the folder containing compiled py modules
pyc_path = __BRYTHON__.brython_path + '../tests/pycache'
sys.path[0] = pyc_path

# Optimize module imports
# i.e only send AJAX requests for .pyc.js files when processing this path
from _importlib import optimize_import_for_path
optimize_import_for_path(pyc_path, 'pyc.js')

try:
    from hello_pyc2 import *

    assert get_hello() == 'Hello from pyc2'
    assert world.get_world() == 'pyc2 world'

    import foo_pyc2
    assert foo_pyc2.get_foo() == 'foo from pyc2'
    assert foo_pyc2.get_bar() == 'bar from pyc2'

    # Assertions for issue #7
    import test_issue7_pyc2 # brythontest2 in #7 => test_issue7_pyc2
    test_issue7_pyc2.xxx = 123
    assert test_issue7_pyc2.xxx == 123
Пример #3
0
# pylint: skip-file
from browser import window
from _importlib import optimize_import_for_path
optimize_import_for_path(window.RUR.BASE_URL + '/src/python', 'py')
from common import __generic_translate_python
window['translate_python'] = __generic_translate_python
import py_repl
Пример #4
0
from browser import window
from _importlib import optimize_import_for_path
optimize_import_for_path(window.RUR._BASE_URL + '/src/python', 'py')
from common import generic_translate_python
window['translate_python'] = generic_translate_python
import py_repl