use emscripten virtual FS directly to load paths (#870)

* use emscripten virtual FS directly to load paths

* use more low level APIs

* use await instead of then

* remove try...catch from loadFromFile since it's being handled externally

* add test for an invalid path

* test checks for error shown to the user too

* add comment about a missing case
This commit is contained in:
Madhur Tandon
2022-10-21 18:43:03 +05:30
committed by GitHub
parent c352b502c4
commit 0cfe20ca65
3 changed files with 31 additions and 17 deletions

View File

@@ -75,6 +75,27 @@ class TestBasic(PyScriptTest):
"hello from B",
]
def test_paths_that_do_not_exist(self):
self.pyscript_run(
"""
<py-config>
paths = ["./f.py"]
</py-config>
"""
)
assert self.console.error.lines == ["Failed to load resource: net::ERR_FAILED"]
assert self.console.warning.lines == [
"Caught an error in fetchPaths:\r\n TypeError: Failed to fetch"
]
errorContent = """PyScript: Access to local files
(using "Paths:" in &lt;py-config&gt;)
is not available when directly opening a HTML file;
you must use a webserver to serve the additional files."""
inner_html = self.page.locator(".py-error").inner_html()
assert errorContent in inner_html
def test_packages(self):
self.pyscript_run(
"""