mirror of
https://github.com/pyscript/pyscript.git
synced 2026-02-21 11:01:26 -05:00
Fix test_async and test_stdio_handling (#1319)
Resolves pyscript#1313 and pyscript#1314. On top of pyscript#1318. The point of these tests is to define the execution order of Tasks that are scheduled in <py-script> tags: first all the py-script tags are executed and their related lifecycle events. Once all of this is done, we schedule any enqueued tasks. To delay the execution of these tasks, we use a custom event loop for pyExec with this defer behavior. Until schedule_deferred_tasks is called, we defer tasks started by user code. schedule_deferred_tasks starts all deferred user tasks and switches to immediately scheduling any further user tasks.
This commit is contained in:
@@ -192,16 +192,15 @@ class TestBasic(PyScriptTest):
|
||||
assert self.console.log.lines[-1] == "hello from foo"
|
||||
|
||||
def test_py_script_src_not_found(self):
|
||||
self.pyscript_run(
|
||||
"""
|
||||
<py-script src="foo.py"></py-script>
|
||||
"""
|
||||
)
|
||||
with pytest.raises(JsErrors) as exc:
|
||||
self.pyscript_run(
|
||||
"""
|
||||
<py-script src="foo.py"></py-script>
|
||||
"""
|
||||
)
|
||||
assert self.PY_COMPLETE in self.console.log.lines
|
||||
|
||||
assert "Failed to load resource" in self.console.error.lines[0]
|
||||
with pytest.raises(JsErrors) as exc:
|
||||
self.check_js_errors()
|
||||
|
||||
error_msgs = str(exc.value)
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import pytest
|
||||
|
||||
from .support import PyScriptTest
|
||||
|
||||
|
||||
@@ -124,7 +122,6 @@ class TestAsync(PyScriptTest):
|
||||
inner_text = self.page.inner_text("html")
|
||||
assert "A0\nA1\nB0\nB1" in inner_text
|
||||
|
||||
@pytest.mark.xfail(reason="fails after introducing synclink, fix me soon!")
|
||||
def test_async_display_untargeted(self):
|
||||
self.pyscript_run(
|
||||
"""
|
||||
@@ -151,7 +148,6 @@ class TestAsync(PyScriptTest):
|
||||
== "Implicit target not allowed here. Please use display(..., target=...)"
|
||||
)
|
||||
|
||||
@pytest.mark.xfail(reason="fails after introducing synclink, fix me soon!")
|
||||
def test_sync_and_async_order(self):
|
||||
"""
|
||||
The order of execution is defined as follows:
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import pytest
|
||||
|
||||
from .support import PyScriptTest
|
||||
|
||||
|
||||
@@ -100,7 +98,6 @@ class TestOutputHandling(PyScriptTest):
|
||||
|
||||
self.assert_no_banners()
|
||||
|
||||
@pytest.mark.xfail(reason="fails after introducing synclink, fix me soon!")
|
||||
def test_targeted_stdio_async(self):
|
||||
# Test the behavior of stdio capture in async contexts
|
||||
self.pyscript_run(
|
||||
@@ -149,7 +146,6 @@ class TestOutputHandling(PyScriptTest):
|
||||
|
||||
self.assert_no_banners()
|
||||
|
||||
@pytest.mark.xfail(reason="fails after introducing synclink, fix me soon!")
|
||||
def test_targeted_stdio_interleaved(self):
|
||||
# Test that synchronous writes to stdout are placed correctly, even
|
||||
# While interleaved with scheduling coroutines in the same tag
|
||||
|
||||
@@ -3,3 +3,4 @@ from unittest.mock import Mock
|
||||
|
||||
document = Mock()
|
||||
console = Mock()
|
||||
setTimeout = Mock()
|
||||
|
||||
Reference in New Issue
Block a user