mirror of
https://github.com/pyscript/pyscript.git
synced 2026-02-18 22:00:37 -05:00
Update test suite (#2181)
* pyscript.web tests pass with upytest. * Refactor of old integration tests to new Python tests. * Added comprehensive test suite for Python based `pyscript` module. * Add integration tests to Makefile (and CI) * Remove un-needed upload action. * Ensure fails are properly logged as an array. Remove the explicit test step, since this is already built into the build step. * Bump polyscript. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Andrea Giammarchi <andrea.giammarchi@gmail.com>
This commit is contained in:
committed by
GitHub
parent
ae66d13d57
commit
06138bbb48
60
pyscript.core/tests/javascript/hooks.html
Normal file
60
pyscript.core/tests/javascript/hooks.html
Normal file
@@ -0,0 +1,60 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>PyScript Next Plugin Bug?</title>
|
||||
<link rel="stylesheet" href="../../dist/core.css">
|
||||
<script type="module">
|
||||
addEventListener('mpy:done', () => {
|
||||
document.documentElement.classList.add('done');
|
||||
});
|
||||
|
||||
import { hooks } from "../../dist/core.js";
|
||||
|
||||
// Main
|
||||
hooks.main.onReady.add((wrap, element) => {
|
||||
console.log("main", "onReady");
|
||||
if (location.search === '?debug') {
|
||||
console.debug("main", "wrap", wrap);
|
||||
console.debug("main", "element", element);
|
||||
}
|
||||
});
|
||||
hooks.main.onBeforeRun.add(() => {
|
||||
console.log("main", "onBeforeRun");
|
||||
});
|
||||
hooks.main.codeBeforeRun.add('print("main", "codeBeforeRun")');
|
||||
hooks.main.codeAfterRun.add('print("main", "codeAfterRun")');
|
||||
hooks.main.onAfterRun.add(() => {
|
||||
console.log("main", "onAfterRun");
|
||||
});
|
||||
|
||||
// Worker
|
||||
hooks.worker.onReady.add((wrap, xworker) => {
|
||||
console.log("worker", "onReady");
|
||||
if (location.search === '?debug') {
|
||||
console.debug("worker", "wrap", wrap);
|
||||
console.debug("worker", "xworker", xworker);
|
||||
}
|
||||
});
|
||||
hooks.worker.onBeforeRun.add(() => {
|
||||
console.log("worker", "onBeforeRun");
|
||||
});
|
||||
hooks.worker.codeBeforeRun.add('print("worker", "codeBeforeRun")');
|
||||
hooks.worker.codeAfterRun.add('print("worker", "codeAfterRun")');
|
||||
hooks.worker.onAfterRun.add(() => {
|
||||
console.log("worker", "onAfterRun");
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="mpy" async="false" worker>
|
||||
from pyscript import document
|
||||
print("actual code in worker")
|
||||
document.documentElement.classList.add('worker')
|
||||
</script>
|
||||
<script type="mpy" async="false">
|
||||
print("actual code in main")
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user