mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-23 22:00:25 -05:00
* Fix #2114 - Cleanup the test folder + automation * Merged both test and tests into a single folder
This commit is contained in:
committed by
GitHub
parent
f4c4edeb29
commit
9f46234f71
2
pyscript.core/tests/py-editor/config.toml
Normal file
2
pyscript.core/tests/py-editor/config.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
[js_modules.worker]
|
||||
"https://cdn.jsdelivr.net/npm/html-escaper/+esm" = "html_escaper"
|
||||
55
pyscript.core/tests/py-editor/index.html
Normal file
55
pyscript.core/tests/py-editor/index.html
Normal file
@@ -0,0 +1,55 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="../../dist/core.css">
|
||||
<script type="module">
|
||||
import '../../dist/core.js';
|
||||
|
||||
addEventListener('mpy-editor', async ({ target }) => {
|
||||
if (target.hasAttribute('setup')) {
|
||||
await target.process([
|
||||
'from pyscript import document',
|
||||
// adds class="a-1" to the <html> element
|
||||
'document.documentElement.classList.add(f"a-{a}")',
|
||||
'from js import console',
|
||||
'console.log("Hello JS")',
|
||||
].join('\n'));
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<!-- a setup node with a config for an env -->
|
||||
<script type="mpy-editor" src="task1.py" config="./config.toml" env="task1" setup></script>
|
||||
<script type="mpy-editor" env="task1">
|
||||
from pyscript.js_modules.html_escaper import escape, unescape
|
||||
print(unescape(escape("<OK>")))
|
||||
a = 1
|
||||
</script>
|
||||
<!-- a share-nothing micropython editor -->
|
||||
<script type="mpy-editor" config='{"js_modules":{"worker":{"https://cdn.jsdelivr.net/npm/html-escaper/+esm":"html_escaper"}}}'>
|
||||
from pyscript.js_modules.html_escaper import escape, unescape
|
||||
print(unescape(escape("<OK>")))
|
||||
b = 2
|
||||
try:
|
||||
print(a)
|
||||
except:
|
||||
print("all good")
|
||||
</script>
|
||||
<!-- a config once micropython env -->
|
||||
<script type="mpy-editor" env="task2" config="./config.toml">
|
||||
from pyscript.js_modules.html_escaper import escape, unescape
|
||||
print(unescape(escape("<OK>")))
|
||||
c = 3
|
||||
try:
|
||||
print(b)
|
||||
except:
|
||||
print("all good")
|
||||
</script>
|
||||
<script type="mpy-editor" env="task2">
|
||||
print(c)
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
17
pyscript.core/tests/py-editor/issue-2056.html
Normal file
17
pyscript.core/tests/py-editor/issue-2056.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="../../dist/core.css">
|
||||
<script type="module" src="../../dist/core.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="py-editor">
|
||||
print("Hello!")
|
||||
</script>
|
||||
<script type="mpy-editor">
|
||||
print("Hello!")
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
16
pyscript.core/tests/py-editor/service-worker.html
Normal file
16
pyscript.core/tests/py-editor/service-worker.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="../../dist/core.css">
|
||||
<script type="module" src="../../dist/core.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="mpy-editor" service-worker="./sw.js">
|
||||
from pyscript import document
|
||||
|
||||
document.body.append("OK")
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
1
pyscript.core/tests/py-editor/sw.js
Normal file
1
pyscript.core/tests/py-editor/sw.js
Normal file
@@ -0,0 +1 @@
|
||||
const{isArray:e}=Array,t=new Map,s=e=>{e.stopImmediatePropagation(),e.preventDefault()};var n=Object.freeze({__proto__:null,activate:e=>e.waitUntil(clients.claim()),fetch:e=>{const{request:n}=e;"POST"===n.method&&n.url===`${location.href}?sabayon`&&(s(e),e.respondWith(n.json().then((async e=>{const{promise:s,resolve:o}=Promise.withResolvers(),a=e.join(",");t.set(a,o);for(const t of await clients.matchAll())t.postMessage(e);return s.then((e=>new Response(`[${e.join(",")}]`,n.headers)))}))))},install:()=>skipWaiting(),message:n=>{const{data:o}=n;if(e(o)&&4===o.length){const[e,a,i,r]=o,l=[e,a,i].join(",");t.has(l)&&(s(n),t.get(l)(r),t.delete(l))}}});for(const e in n)addEventListener(e,n[e]);
|
||||
5
pyscript.core/tests/py-editor/task1.py
Normal file
5
pyscript.core/tests/py-editor/task1.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from pyscript import window
|
||||
|
||||
window.console.log("OK")
|
||||
|
||||
a = 1
|
||||
Reference in New Issue
Block a user