mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
* Add media Python tests * Add media js test * Remove try except blocks * Make Python tests more end-to-end * Add media Python tests * Add media js test * Remove try except blocks * Make Python tests more end-to-end * MicroPython explorations. * Fix websocket tests, so they just skip. * Fix MicroPython media tests, if no permission is given for a video device. --------- Co-authored-by: Nicholas H.Tollervey <ntoll@ntoll.org> Co-authored-by: Andrea Giammarchi <andrea.giammarchi@gmail.com>
40 lines
1.3 KiB
HTML
40 lines
1.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Pyodide Media Module Test</title>
|
|
<link rel="stylesheet" href="../../dist/core.css">
|
|
<script type="module" src="../../dist/core.js"></script>
|
|
</head>
|
|
<body>
|
|
<h1>Pyodide Media Module Test</h1>
|
|
<div id="test-results">Running tests...</div>
|
|
|
|
<script type="py" terminal>
|
|
from pyscript import window, document
|
|
from pyscript import media
|
|
|
|
async def run_tests():
|
|
# Test basic module structure
|
|
assert hasattr(media, "Device"), "media module should have Device class"
|
|
assert hasattr(media, "list_devices"), "media module should have list_devices function"
|
|
|
|
# Test device enumeration
|
|
devices = await media.list_devices()
|
|
assert isinstance(devices, list), "list_devices should return a list"
|
|
|
|
# If we have devices, test properties of one
|
|
if devices:
|
|
device = devices[0]
|
|
assert hasattr(device, "id"), "Device should have id property"
|
|
assert hasattr(device, "group"), "Device should have group property"
|
|
assert hasattr(device, "kind"), "Device should have kind property"
|
|
assert hasattr(device, "label"), "Device should have label property"
|
|
|
|
document.getElementById('test-results').innerText = "Success!"
|
|
document.documentElement.classList.add('media-ok')
|
|
|
|
await run_tests()
|
|
</script>
|
|
</body>
|
|
</html>
|