mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
Before this PR, the following test passed:
def test_pyscript_hello(self):
self.pyscript_run(
"""
<script type="py">
raise Exception("hello")
</script>
""")
What happens is that we intercept the Python exception and display a nice banner on the DOM, but the test itself passes. This is error prone: if we have Python exceptions on the page, the test should fail by default, and we should have a way to silence it in case those exceptions are expected.
This PR treats Python errors as we treat JS errors: unhandled exceptions cause the test to fail, but you can silence them by calling self.check_py_errors(), exactly as you can call self.check_js_errors().
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
from playwright.sync_api import expect
|
|
|
|
from .support import PyScriptTest, skip_worker
|
|
|
|
|
|
class TestStyle(PyScriptTest):
|
|
def test_pyscript_not_defined(self):
|
|
"""Test raw elements that are not defined for display:none"""
|
|
doc = """
|
|
<html>
|
|
<head>
|
|
<link rel="stylesheet" href="build/pyscript.css" />
|
|
</head>
|
|
<body>
|
|
<py-config>hello</py-config>
|
|
<py-script>hello</py-script>
|
|
<py-repl>hello</py-repl>
|
|
</body>
|
|
</html>
|
|
"""
|
|
self.writefile("test-not-defined-css.html", doc)
|
|
self.goto("test-not-defined-css.html")
|
|
expect(self.page.locator("py-config")).to_be_hidden()
|
|
expect(self.page.locator("py-script")).to_be_hidden()
|
|
expect(self.page.locator("py-repl")).to_be_hidden()
|
|
|
|
@skip_worker("FIXME: display()")
|
|
def test_pyscript_defined(self):
|
|
"""Test elements have visibility that should"""
|
|
self.pyscript_run(
|
|
"""
|
|
<py-config>
|
|
name = "foo"
|
|
</py-config>
|
|
<py-script>display("hello")</py-script>
|
|
<py-repl>display("hello")</py-repl>
|
|
"""
|
|
)
|
|
expect(self.page.locator("py-config")).to_be_hidden()
|
|
expect(self.page.locator("py-script")).to_be_visible()
|
|
expect(self.page.locator("py-repl")).to_be_visible()
|