Add an id if the user forgot when using py-attribute (#1122)

This commit is contained in:
Fábio Rosado
2023-01-21 20:48:27 +00:00
committed by GitHub
parent 35de3aa154
commit 7947a8a2dc
3 changed files with 21 additions and 3 deletions

View File

@@ -305,3 +305,18 @@ class TestBasic(PyScriptTest):
"'py-keydown=\"myFunction()\"' instead."
)
assert banner.inner_text() == expected_message
def test_py_attribute_without_id(self):
self.pyscript_run(
"""
<button py-click="myfunc()">Click me</button>
<py-script>
def myfunc():
print("hello world!")
</py-script>
"""
)
btn = self.page.wait_for_selector("button")
btn.click()
assert self.console.log.lines[-1] == "hello world!"
assert self.console.error.lines == []