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:
Hood Chatham
2023-03-30 14:38:51 -07:00
committed by GitHub
parent b61e8435d1
commit e9122bca9d
7 changed files with 84 additions and 19 deletions

View File

@@ -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: