mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-23 04:03:00 -05:00
Bring tests to next (#1657)
* bring Makefile to root folder * add back the print to console when pyscript is ready * fix build path on tests, link to core.js and overall timeout since it now loads faster * fix and mark some tests accordingly * change default timeout to 20s * review tests and skip what is a known regression * more tests review until pycondif and skip what is a known regression * fix pyodide version used on tests * remove display from config test since it's not testing anything more than console already tests and display as its own tests * disable config tests that rely on the banner * skip REPL tests since it's not included in pyscript NEXT * skip PyTerminal tests since it's not included in pyscript NEXT * skip more tests relying on Element * Fix wrong script type from py-script to py * review more tests related to attributes and add test for worker * skip spashscreen tests * wrap up reviews on remaining tests * update core * update display tests to use import * fix more tests and skip some that have known issues * skip other 2 tests that fail because the test framework injects values that cause the config to fail * fix getPySrc test due to changed interface * another round of fixes and commenting on specific tests --------- Co-authored-by: Fabio Pliger <fpliger@anaconda.com>
This commit is contained in:
@@ -8,14 +8,19 @@ import requests
|
||||
|
||||
from .support import PyScriptTest, with_execution_thread
|
||||
|
||||
PYODIDE_VERSION = "0.23.4"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def pyodide_0_22_0_tar(request):
|
||||
def pyodide_tar(request):
|
||||
"""
|
||||
Fixture which returns a local copy of pyodide. It uses pytest-cache to
|
||||
avoid re-downloading it between runs.
|
||||
"""
|
||||
URL = "https://github.com/pyodide/pyodide/releases/download/0.22.0/pyodide-core-0.22.0.tar.bz2"
|
||||
URL = (
|
||||
f"https://github.com/pyodide/pyodide/releases/download/{PYODIDE_VERSION}/"
|
||||
f"pyodide-core-{PYODIDE_VERSION}.tar.bz2"
|
||||
)
|
||||
tar_name = Path(URL).name
|
||||
|
||||
val = request.config.cache.get(tar_name, None)
|
||||
@@ -45,6 +50,9 @@ def unzip(location, extract_to="."):
|
||||
# of config
|
||||
@with_execution_thread(None)
|
||||
class TestConfig(PyScriptTest):
|
||||
@pytest.mark.skip(
|
||||
"FIXME: API has changed and there's no pyscript_get_config anymore"
|
||||
)
|
||||
def test_py_config_inline(self):
|
||||
self.pyscript_run(
|
||||
"""
|
||||
@@ -61,6 +69,9 @@ class TestConfig(PyScriptTest):
|
||||
)
|
||||
assert self.console.log.lines[-1] == "config name: foobar"
|
||||
|
||||
@pytest.mark.skip(
|
||||
"FIXME: API has changed and there's no pyscript_get_config anymore"
|
||||
)
|
||||
def test_py_config_external(self):
|
||||
pyconfig_toml = """
|
||||
name = "app with external config"
|
||||
@@ -87,8 +98,8 @@ class TestConfig(PyScriptTest):
|
||||
# The test checks if loading a different interpreter is possible
|
||||
# and that too from a locally downloaded file without needing
|
||||
# the use of explicit `indexURL` calculation.
|
||||
def test_interpreter_config(self, pyodide_0_22_0_tar):
|
||||
unzip(pyodide_0_22_0_tar, extract_to=self.tmpdir)
|
||||
def test_interpreter_config(self, pyodide_tar):
|
||||
unzip(pyodide_tar, extract_to=self.tmpdir)
|
||||
self.pyscript_run(
|
||||
"""
|
||||
<py-config type="json">
|
||||
@@ -105,19 +116,15 @@ class TestConfig(PyScriptTest):
|
||||
import sys, js
|
||||
pyodide_version = sys.modules["pyodide"].__version__
|
||||
js.console.log("version", pyodide_version)
|
||||
display(pyodide_version)
|
||||
</py-script>
|
||||
""",
|
||||
)
|
||||
|
||||
assert self.console.log.lines[-1] == "version 0.22.0"
|
||||
version = self.page.locator("py-script").inner_text()
|
||||
assert version == "0.22.0"
|
||||
assert self.console.log.lines[-1] == f"version {PYODIDE_VERSION}"
|
||||
|
||||
def test_runtime_still_works_but_shows_deprecation_warning(
|
||||
self, pyodide_0_22_0_tar
|
||||
):
|
||||
unzip(pyodide_0_22_0_tar, extract_to=self.tmpdir)
|
||||
@pytest.mark.skip("FIXME: We need to restore the banner.")
|
||||
def test_runtime_still_works_but_shows_deprecation_warning(self, pyodide_tar):
|
||||
unzip(pyodide_tar, extract_to=self.tmpdir)
|
||||
self.pyscript_run(
|
||||
"""
|
||||
<py-config type="json">
|
||||
@@ -134,14 +141,11 @@ class TestConfig(PyScriptTest):
|
||||
import sys, js
|
||||
pyodide_version = sys.modules["pyodide"].__version__
|
||||
js.console.log("version", pyodide_version)
|
||||
display(pyodide_version)
|
||||
</py-script>
|
||||
""",
|
||||
)
|
||||
|
||||
assert self.console.log.lines[-1] == "version 0.22.0"
|
||||
version = self.page.locator("py-script").inner_text()
|
||||
assert version == "0.22.0"
|
||||
assert self.console.log.lines[-1] == f"version {PYODIDE_VERSION}"
|
||||
|
||||
deprecation_banner = self.page.wait_for_selector(".alert-banner")
|
||||
expected_message = (
|
||||
@@ -150,6 +154,7 @@ class TestConfig(PyScriptTest):
|
||||
)
|
||||
assert deprecation_banner.inner_text() == expected_message
|
||||
|
||||
@pytest.mark.skip("FIXME: We need to restore the banner.")
|
||||
def test_invalid_json_config(self):
|
||||
# we need wait_for_pyscript=False because we bail out very soon,
|
||||
# before being able to write 'PyScript page fully initialized'
|
||||
@@ -169,6 +174,7 @@ class TestConfig(PyScriptTest):
|
||||
)
|
||||
assert banner.inner_text() == expected
|
||||
|
||||
@pytest.mark.skip("FIXME: We need to restore the banner.")
|
||||
def test_invalid_toml_config(self):
|
||||
# we need wait_for_pyscript=False because we bail out very soon,
|
||||
# before being able to write 'PyScript page fully initialized'
|
||||
@@ -189,6 +195,7 @@ class TestConfig(PyScriptTest):
|
||||
)
|
||||
assert banner.inner_text() == expected
|
||||
|
||||
@pytest.mark.skip("FIXME: We need to restore the banner.")
|
||||
def test_multiple_py_config(self):
|
||||
self.pyscript_run(
|
||||
"""
|
||||
@@ -214,6 +221,7 @@ class TestConfig(PyScriptTest):
|
||||
)
|
||||
assert banner.text_content() == expected
|
||||
|
||||
@pytest.mark.skip("FIXME: We need to restore the banner.")
|
||||
def test_no_interpreter(self):
|
||||
snippet = """
|
||||
<py-config type="json">
|
||||
@@ -228,6 +236,7 @@ class TestConfig(PyScriptTest):
|
||||
div.text_content() == "(PY1000): Fatal error: config.interpreter is empty"
|
||||
)
|
||||
|
||||
@pytest.mark.skip("FIXME: We need to restore the banner.")
|
||||
def test_multiple_interpreter(self):
|
||||
snippet = """
|
||||
<py-config type="json">
|
||||
@@ -283,6 +292,7 @@ class TestConfig(PyScriptTest):
|
||||
"hello from B",
|
||||
]
|
||||
|
||||
@pytest.mark.skip("FIXME: We need to restore the banner.")
|
||||
def test_paths_that_do_not_exist(self):
|
||||
self.pyscript_run(
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user