Handle non-200 code when fetch py-script src (#940)

This commit is contained in:
Fábio Rosado
2022-11-12 10:07:51 +00:00
committed by GitHub
parent 3c3dffd5ed
commit b445f8a834
2 changed files with 32 additions and 4 deletions

View File

@@ -1,4 +1,6 @@
from .support import PyScriptTest
import pytest
from .support import JsErrors, PyScriptTest
class TestBasic(PyScriptTest):
@@ -126,3 +128,22 @@ class TestBasic(PyScriptTest):
self.PY_COMPLETE,
"hello from foo",
]
def test_py_script_src_not_found(self):
self.pyscript_run(
"""
<py-script src="foo.py"></py-script>
"""
)
assert self.console.log.lines == [
self.PY_COMPLETE,
]
assert "Failed to load resource" in self.console.error.lines[0]
with pytest.raises(JsErrors) as exc:
self.check_js_errors()
error_msg = str(exc.value)
assert "Failed to fetch" in error_msg
pyscript_tag = self.page.locator("py-script")
assert pyscript_tag.inner_html() == ""