mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-20 10:47:35 -05:00
* Loading and Script evaluate with Promise.all * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Move to 'void script.evaluate();' * chmod files to 644 * Add a test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
37 lines
900 B
Python
37 lines
900 B
Python
from .support import PyScriptTest
|
|
|
|
|
|
class TestAsync(PyScriptTest):
|
|
def test_multiple_async(self):
|
|
self.pyscript_run(
|
|
"""
|
|
<py-script>
|
|
import js
|
|
import asyncio
|
|
for i in range(3):
|
|
js.console.log('A', i)
|
|
await asyncio.sleep(0.1)
|
|
</py-script>
|
|
|
|
<py-script>
|
|
import js
|
|
import asyncio
|
|
for i in range(3):
|
|
js.console.log('B', i)
|
|
await asyncio.sleep(0.1)
|
|
js.console.log("async tadone")
|
|
</py-script>
|
|
"""
|
|
)
|
|
self.wait_for_console("async tadone")
|
|
assert self.console.log.lines == [
|
|
"Python initialization complete",
|
|
"A 0",
|
|
"B 0",
|
|
"A 1",
|
|
"B 1",
|
|
"A 2",
|
|
"B 2",
|
|
"async tadone",
|
|
]
|