-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support running pytest under WASI #10670
Comments
I think webassembly support should be a high priority for Pytest, because it would be so helpful for other packages and maintainers trying to support Python in the browser. I hit similar issues in my Hypothesis Ghostwriter demo, and had to collect and call test functions by hand 😰 I tend to think about this in three stages:
|
Is there any way to add some kind of wasi pipeline that gives output to our ci? Same would go for a headless call to it that gives us the output Currently I'm under the impression that none of the pytest maintainers has familiarity with wasi |
For what it's worth, you should be able to run with |
lets add a gh pipeline that runs pytests own testsuite on wasi as a starting point, then continue from there |
This actually came about because I want to document for folks how to test their own stuff at https://github.com/python/cpython/tree/main/Tools/wasm for those willing to be bleeding edge with this sort of thing. My hope was to show a pytest example, but I may have to start with
Probably, but it might be a bit janky to start. My hope is we will start releasing official WASI builds of CPython for 3.12 once WASI support reaches tier 2 (I'm already working towards this). So I can also totally understand wanting to wait until that occurs before trying to tackle this in any official capacity. My main reason for opening this issue was as an FYI for you all and to have an issue available for anyone else who may bump into this while trying stuff out, but I do appreciate that people seemed interesting in seeing if there's a way to make this work somehow! |
Got the help output! wasmtime run --dir=. --dir=/dev --allow-precompiled python.cwasm -- -m pytest -s -p no:faulthandler -h |
I also managed to get the test suite for |
What's the problem this feature will solve?
I'm trying to run pytest under the WASI build of CPython, but pytest's extensive use of
os.dup()
prevents it from working.If you're curious to reproduce:
python.wasm
:PIP_REQUIRE_VIRTUALENV=0 py -3.11 -m pip install --target . --only-binary=:all: --implementation=py --abi=none --abi=any pytest
(if you don't have the Python Launcher, take out-3.11
and add the pip flag--python_version="3.11"
)wasmtime run --dir=. python.wasm -- -m pytest -h
It looks like:
pytest/src/_pytest/capture.py
Line 381 in 03b1994
is the first instance of
os.dup()
you run into, but even with--capture=no
/s
, you still run into:pytest/src/_pytest/faulthandler.py
Line 29 in 61cfaac
Describe the solution you'd like
I would love to be able to provide instructions to projects on how to run pytest under WASI to see if their project is compatible.
Alternative Solutions
Additional context
The text was updated successfully, but these errors were encountered: