Functions exported from a worker should be callable.
()
| 33 | |
| 34 | @upytest.skip("Main thread only", skip_when=RUNNING_IN_WORKER) |
| 35 | async def test_worker_exported_functions(): |
| 36 | """ |
| 37 | Functions exported from a worker should be callable. |
| 38 | """ |
| 39 | from pyscript import workers |
| 40 | |
| 41 | worker = await workers["testworker"] |
| 42 | # Test multiple exported functions. |
| 43 | add_result = await worker.add(10, 20) |
| 44 | multiply_result = await worker.multiply(4, 5) |
| 45 | greeting = await worker.get_message() |
| 46 | |
| 47 | assert add_result == 30 |
| 48 | assert multiply_result == 20 |
| 49 | assert greeting == "Hello from worker" |
| 50 | |
| 51 | |
| 52 | @upytest.skip("Main thread only", skip_when=RUNNING_IN_WORKER) |