Rm id use (#912)

* rm unecessary code on output rendering on pyscript.py

* Remove all ids from repl

* Fix problems on rendering outside repl

* fixing tests

* Fixes repl and tes_py_repl

* Fix zz tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test 864now works consistently

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Mariana Meireles
2022-12-02 00:59:21 +01:00
committed by GitHub
parent 33d49ad87d
commit 72e23ac86f
4 changed files with 45 additions and 31 deletions

View File

@@ -157,7 +157,7 @@ class TestExamples(PyScriptTest):
# at the mpl-1 div which is rendered once the image is in the page
# if this test fails, confirm that the div has the right id using
# the --dev flag when running the tests
test = self.page.wait_for_selector("#mpl-1 >> img")
test = self.page.wait_for_selector("#mpl >> img")
img_src = test.get_attribute("src").replace(
"data:image/png;charset=utf-8;base64,", ""
)
@@ -256,7 +256,6 @@ class TestExamples(PyScriptTest):
assert self.page.title() == "PyScript/Panel Streaming Demo"
wait_for_render(self.page, "*", "<div.*?class=['\"]bk-root['\"].*?>")
@pytest.mark.skip("flaky test, see issue #864")
def test_repl(self):
self.goto("examples/repl.html")
self.wait_for_pyscript()
@@ -266,15 +265,15 @@ class TestExamples(PyScriptTest):
self.page.locator("py-repl").type("display('Hello, World!')")
self.page.locator("#runButton").click()
assert self.page.locator("#my-repl-2").text_content() == "Hello, World!"
assert self.page.locator("#my-repl-1").text_content() == "Hello, World!"
# Confirm that using the second repl still works properly
self.page.locator("#my-repl-2").type("display(2*2)")
self.page.keyboard.press("Shift+Enter")
# Make sure that the child of the second repl is attached properly
# before looking into the text_content
assert self.page.wait_for_selector("#my-repl-2-1", state="attached")
assert self.page.locator("#my-repl-2-1").text_content() == "4"
assert self.page.wait_for_selector("#my-repl-2-2", state="attached")
assert self.page.locator("#my-repl-2-2").text_content() == "4"
def test_repl2(self):
self.goto("examples/repl2.html")
@@ -285,7 +284,7 @@ class TestExamples(PyScriptTest):
self.page.locator("py-repl").type("import utils\ndisplay(utils.now())")
self.page.wait_for_selector("#runButton").click()
# Make sure the output is in the page
self.page.wait_for_selector("#my-repl-1-1")
self.page.wait_for_selector("#my-repl-1")
# utils.now returns current date time
content = self.page.content()
pattern = "\\d+/\\d+/\\d+, \\d+:\\d+:\\d+" # e.g. 08/09/2022 15:57:32