-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Enable worker tests #1757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable worker tests #1757
Conversation
@JeffersGlass to continue the conversation started in the other PR, here is my WIP PR which among the other things fixes At the moment it's a ugly hack because it hardcodes a pyscript/pyscript.core/src/core.js Lines 91 to 103 in 588eda8
@WebReflection is working on a better solution which uses hooks instead of hardcoding the prints. |
…finished their execution
…able worker tests
479e2ec
to
f554fdb
Compare
…ide 0.24.1, probably because of a different pillow version
@pytest.mark.skip( | ||
reason="FIXME: No banner and should also add a WARNING about CORS" | ||
) | ||
@pytest.mark.skip(reason="NEXT: No banner and should also add a WARNING about CORS") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it just CORS or all the worker related headers?
@@ -104,6 +110,7 @@ def test_python_exception(self): | |||
assert tb_lines[0] == "Traceback (most recent call last):" | |||
assert tb_lines[-1] == "Exception: this is an error" | |||
|
|||
@skip_worker("NEXT: py-click doesn't work inside workers") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. 10000 Learn more.
this is not really a skip, this is fundamentally impossible to relate to a worker from the main thread ... which worker? to start with ... and should we really offer this functionality when we have a @when
decorator that works within Python code in workers too, as long as the ID exists on the main thread?
@@ -151,20 +159,24 @@ def test_execution_in_order(self): | |||
"four", | |||
] | |||
|
|||
@skip_worker("NEXT: something very weird happens here") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this info is a bit cryptic ... what is weird in this test?
def test_escaping_of_angle_brackets(self): | ||
""" | ||
Check that script tags escape angle brackets | ||
""" | ||
self.pyscript_run( | ||
""" | ||
<script type="py">import js; js.console.log("A", 1<2, 1>2)</script> | ||
<script type="py">js.console.log("B <div></div>")</script> | ||
<script type="py">import js; js.console.log("B <div></div>")</script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only weird thing I see is that we use the worker global console
while maybe we check/test the main thread one ... in that case it's from pyscript import window; window.console.log(...)
@@ -191,7 +203,7 @@ def test_packages(self): | |||
"hello asciitree", # printed by us | |||
] | |||
|
|||
@pytest.mark.skip("FIXME: No banner") | |||
@pytest.mark.skip("NEXT: No banner") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if by banner we mean the DOM related to the error, it's a div.py-error
from the error plugin.
@@ -301,7 +310,7 @@ def test_js_version(self): | |||
) | |||
|
|||
# TODO: ... and we shouldn't: it's a module and we better don't leak in global | |||
@pytest.mark.skip("DIFFERENT BEHAVIOUR: we don't expose pyscript on window") | |||
@pytest.mark.skip("NEXT: we don't expose pyscript on window") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import pyscript
works in either main (window?) or worker so I am not sure I understand this skip message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is about leaking globally pyscript on window, we dont' do that anymore, and likely we shouldn't ... as we land a module, and we discussed already, and filed issues and MRs, aroud not leaking on global.
@@ -68,6 +72,7 @@ def test_target_parameter(self): | |||
mydiv = self.page.locator("#mydiv") | |||
assert mydiv.inner_text() == "hello world" | |||
|
|||
@skip_worker("NEXT: display(target=...) does not work") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does and it's tested ... maybe it's what we try to grab as element that doesn't work?
@@ -87,6 +92,7 @@ def test_tag_target_attribute(self): | |||
goodbye = self.page.locator("#goodbye") | |||
assert goodbye.inner_text() == "goodbye world" | |||
|
|||
@skip_worker("NEXT: display target does not work properly") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<script>
can't be a visual target ... we talked about it and it's a display issue we need to fix, not a library issue ... there was a discussion around this, remember? if the ID is a <script>
tag, then get its target.id
instead ... this warning is misleading to me.
@@ -163,6 +171,7 @@ def say_hello(): | |||
assert py0.inner_text() == "" | |||
assert py1.inner_text() == "hello" | |||
|
|||
@skip_worker("NEXT: py-click doesn't work") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and it cannot with workers ... see my previous comment.
# waiit_for_pyscript is broken: it waits until the python code is about to | ||
# start, to until the python code has finished execution | ||
@pytest.mark.skip("FIXME: wait_for_pyscript is broken") | ||
@skip_worker("NEXT: matplotlib-pyodide backend does not work") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is cute but it feels like, while we do care about matplotlib working from workers, and it's tested and it does work already, we're testing 3rd party gotchas in our unrelated project. This should (imho) be part of examples tests, not core functionalities.
@@ -30,7 +31,7 @@ def test_py_config_inline_pyscript(self): | |||
) | |||
assert self.console.log.lines[-1] == "config name: foobar" | |||
|
|||
@pytest.mark.skip("ERROR_SCRIPT: works with <py-script> not with <script>") | |||
@pytest.mark.skip("NEXT: works with <py-script> not with <script>") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is misleading ... you are accessing document.currentScript._pyodide.promise
to grab the config
and we landed already an explicit export of the config we pass along ... this needs a rewrite, happy to help if needed, you need to import { config as pyConfig } from 'core.js'
and then globalThis.pyConfig = pyConfig
and change any code that use internals wrongly to reach the config.
expected = ( | ||
"(PY1000): Invalid TOML\n" | ||
"Expected DoubleQuote, Whitespace, or [a-z], [A-Z], " | ||
'[0-9], "-", "_" but end of input found.' | ||
) | ||
assert banner.inner_text() == expected | ||
|
||
@pytest.mark.skip("FIXME: emit a warning in case of multiple py-config") | ||
@pytest.mark.skip("NEXT: emit a warning in case of multiple py-config") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #1745 (comment)
@@ -2,7 +2,7 @@ | |||
|
|||
from .support import PyScriptTest, skip_worker | |||
|
|||
pytest.skip(reason="FIXME: entire stdio should be reviewed", allow_module_level=True) | |||
pytest.skip(reason="NEXT: entire stdio should be reviewed", allow_module_level=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have an issue for this? I am not sure what this is about, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed with @antocuni this MR should move forward so that we can re-enable CI in our PRs and branches. Nothing I've commented is really a blocker so I am going to approve this for the time being, but I'll keep those comments in mind for a possible follow-up MR.
@WebReflection thank you for the approval! |
This PR re-enables tests on
worker
s.Highlights:
<script type="py">
, the worker version automatically turn the tags into<script type="py" worker>
@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
)@only_main
decorator@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 fixedDuring 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.Next steps
main
worker