detect the case in which multiple <py-config> are listed

Ideally I would like it to be a fatal error, but it's too hard to do it with the current state of the code, will refactor it later (#826)
This commit is contained in:
Antonio Cuni
2022-10-04 19:59:59 +02:00
committed by GitHub
parent e8e2e65584
commit 1e05ff7c95
3 changed files with 40 additions and 2 deletions

View File

@@ -131,3 +131,28 @@ class TestConfig(PyScriptTest):
)
msg = str(exc)
assert "<ExceptionInfo JsError" in msg
def test_multiple_py_config(self):
self.pyscript_run(
"""
<py-config>
name = "foobar"
</py-config>
<py-config>
this is ignored and won't even be parsed
</py-config>
<py-script>
import js
config = js.pyscript_get_config()
js.console.log("config name:", config.name)
</py-script>
"""
)
div = self.page.wait_for_selector(".py-error")
expected = (
"Multiple <py-config> tags detected. Only the first "
"is going to be parsed, all the others will be ignored"
)
assert div.text_content() == expected