mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
Enable worker tests (#1757)
This PR re-enables tests on `worker`s. Highlights: * by default, each test is run twice: the main thread version uses `<script type="py">`, the worker version automatically turn the tags into `<script type="py" worker>` * you can tweak the settings per-class by using the `@with_execution_thread` decorator. In particular, `@with_execution_thread(None)` is for those tests which don't care about it (e.g., `test_py_config.py`) * inside each class, there might be some test which should be run only in the main thread (because it doesn't make sense to test it in a worker). For those, I introduced the `@only_main` decorator * we might introduce `@only_worker` in the future, if needed * `@skip_worker` is for those tests which currently pass on main but not on workers. These are meant to be temporary, and eventually they should all be fixed During the process, I tweaked/improved/fixed/deleted some of the existing tests. Some of them were at risk of being flaky and I made them more robust, others depended on some very precise implementation detail, and I made them more generic (for example, `test_image_renders_correctly` relied on pillow to render an image with a very specific string of bytes, and it broke due to the recent upgrade to pyodide 0.24.1) I also renamed all the skip messages to start with `NEXT`, so that they are easier to grep.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import pytest
|
||||
from .support import PyScriptTest, filter_inner_text
|
||||
from .support import PyScriptTest, filter_inner_text, only_main
|
||||
|
||||
|
||||
class TestAsync(PyScriptTest):
|
||||
@@ -52,6 +52,7 @@ class TestAsync(PyScriptTest):
|
||||
self.wait_for_console("DONE")
|
||||
assert self.console.log.lines[-2:] == ["[3, 2, 1]", "DONE"]
|
||||
|
||||
@only_main
|
||||
def test_multiple_async(self):
|
||||
self.pyscript_run(
|
||||
"""
|
||||
@@ -88,6 +89,7 @@ class TestAsync(PyScriptTest):
|
||||
"b func done",
|
||||
]
|
||||
|
||||
@only_main
|
||||
def test_multiple_async_multiple_display_targeted(self):
|
||||
self.pyscript_run(
|
||||
"""
|
||||
@@ -145,6 +147,7 @@ class TestAsync(PyScriptTest):
|
||||
self.wait_for_console("DONE")
|
||||
assert self.page.locator("script-py").inner_text() == "A"
|
||||
|
||||
@only_main
|
||||
def test_sync_and_async_order(self):
|
||||
"""
|
||||
The order of execution is defined as follows:
|
||||
|
||||
Reference in New Issue
Block a user