mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-22 03:35:31 -05:00
Export Version from JS Module (#963)
* Export PyScript version from js module * Add docs and test
This commit is contained in:
@@ -3,6 +3,7 @@ import './styles/pyscript_base.css';
|
||||
import { loadConfigFromElement } from './pyconfig';
|
||||
import type { AppConfig } from './pyconfig';
|
||||
import type { Runtime } from './runtime';
|
||||
import { version } from './runtime';
|
||||
import { PluginManager } from './plugin';
|
||||
import { make_PyScript, initHandlers, mountElements } from './components/pyscript';
|
||||
import { PyodideRuntime } from './pyodide';
|
||||
@@ -261,4 +262,5 @@ globalExport('pyscript_get_config', pyscript_get_config);
|
||||
const globalApp = new PyScriptApp();
|
||||
globalApp.main();
|
||||
|
||||
export { version }
|
||||
export const runtime = globalApp.runtime;
|
||||
|
||||
@@ -150,6 +150,20 @@ class TestBasic(PyScriptTest):
|
||||
pyscript_tag = self.page.locator("py-script")
|
||||
assert pyscript_tag.inner_html() == ""
|
||||
|
||||
def test_js_version(self):
|
||||
self.pyscript_run(
|
||||
"""
|
||||
<py-script>
|
||||
</py-script>
|
||||
"""
|
||||
)
|
||||
self.page.add_script_tag(content="console.log(pyscript.version)")
|
||||
|
||||
assert (
|
||||
re.match(r"\d{4}\.\d{2}\.\d+(\.[a-zA-Z0-9]+)?", self.console.log.lines[-1])
|
||||
is not None
|
||||
)
|
||||
|
||||
def test_python_version(self):
|
||||
self.pyscript_run(
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user