mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-21 03:05:38 -05:00
* Create custom elements when the runtime finishes loading * Remove xfails and fix repl integration test * Fix commented ignore * Address Antonio's comments * Fix bad rebase * Make ure to wait for repl to be in attached state before asserting content * Move createCustomeElement up so it runs before we close the loader, xfail flaky d3 test * Fix xfail
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
from .support import PyScriptTest
|
|
|
|
|
|
class TestPyRepl(PyScriptTest):
|
|
def test_repl_loads(self):
|
|
self.pyscript_run(
|
|
"""
|
|
<py-repl id="my-repl" auto-generate="true"> </py-repl>
|
|
"""
|
|
)
|
|
|
|
py_repl = self.page.query_selector("py-repl")
|
|
assert py_repl
|
|
assert "Python" in py_repl.inner_text()
|
|
|
|
def test_repl_runs_on_button_press(self):
|
|
self.pyscript_run(
|
|
"""
|
|
<py-repl id="my-repl" auto-generate="true"> </py-repl>
|
|
"""
|
|
)
|
|
|
|
self.page.locator("py-repl").type("print(2+2)")
|
|
|
|
# We only have one button in the page
|
|
self.page.locator("button").click()
|
|
|
|
# The result gets the id of the repl + n
|
|
repl_result = self.page.wait_for_selector("#my-repl-1", state="attached")
|
|
|
|
assert repl_result.inner_text() == "4"
|
|
|
|
def test_repl_runs_with_shift_enter(self):
|
|
self.pyscript_run(
|
|
"""
|
|
<py-repl id="my-repl" auto-generate="true"> </py-repl>
|
|
"""
|
|
)
|
|
self.page.locator("py-repl").type("2+2")
|
|
|
|
# Confirm that we get a result by using the keys shortcut
|
|
self.page.keyboard.press("Shift+Enter")
|
|
repl_result = self.page.wait_for_selector("#my-repl-1", state="attached")
|
|
|
|
assert repl_result.text_content() == "4"
|