pytest-dev / pytest-dev/pytest

Support running pytest under WASI

Open
#10,670 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

platform: wasm/wasi type: enhancement
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

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:

  1. Grab a WASI build from https://github.com/tiran/cpython-wasm-test/releases
  2. Unpack it somewhere
  3. From the same directory where you unpacked 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")
  4. Try running wasmtime run --dir=. python.wasm -- -m pytest -h

It looks like:

https://github.com/pytest-dev/pytest/blob/03b19945fb000a82d0012b5720b05cf88c0973be/src/_pytest/capture.py#L381

is the first instance of os.dup() you run into, but even with --capture=no/s, you still run into:

https://github.com/pytest-dev/pytest/blob/61cfaacec695d91ab3b52477f780db4d441170a4/src/_pytest/faulthandler.py#L29

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the WASI CPython build and the provided wasmtime command. Read src/_pytest/capture.py around line 381 and src/_pytest/faulthandler.py around line 29, then determine the scope of WASI-compatible handling; done means pytest can run under WASI and projects have usable instructions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, wasm
Domain
operating-systems, testing-qa
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.