| [ Web Proxy ] |
| Viewing: https://pyodide.org/en/stable/usage/api/python-api/../../../project/../development/testing.html | [Back] [Original] |
Install the following dependencies into the default Python installation:
pip install pytest-pyodide pytest-httpserver
pytest-pyodide is a pytest plugin for testing Pyodide
and third-party applications that use Pyodide.
See: pytest-pyodide for more information.
Install geckodriver or
chromedriver
and check that they are in your PATH.
To run the test suite, run pytest from the root directory of Pyodide:
pytest
There are 2 test locations that are collected by pytest,
src/tests/: general Pyodide tests and tests running the CPython test suite
packages/*/test_*: package specific tests.
You can run the tests from a specific file with:
pytest path/to/test/file.py
Some browsers sometimes produce informative errors than others
so if you are getting confusing errors it is worth rerunning the test on each
browser. You can use --runtime commandline option to specify the browser runtime.
pytest --runtime firefox
pytest --runtime chrome
pytest --runtime node
We support custom test marks:
@pytest.mark.skip_refcount_check and pytest.mark.skip_pyproxy_check disable
respectively the check for JavaScript references and the check for PyProxies.
If a test creates JavaScript references or PyProxies and does not clean them up,
by default the tests will fail. If a test is known to leak objects, it is
possible to disable these checks with these markers.
To run tests on the JavaScript Pyodide package, run the following commands,
cd src/js
npm test
To check TypeScript type definitions run,
npx tsd
To run tests manually:
Build Pyodide, perhaps in the docker image
From outside of the docker image, cd into the dist directory and run
python -m http.server.
Once the webserver is running, simple interactive testing can be run by
visiting the URL: http://localhost:<PORT>/console.html. Its recommended to
use pyodide.runPython in the browser console rather than using the repl.
To run common benchmarks to understand Pyodides performance, begin by installing the same prerequisites as for testing. Then run:
PYODIDE_PACKAGES="numpy,matplotlib" make benchmark
We lint with prek.
Python is linted with ruff (for linting and formatting) and mypy.
JavaScript and TypeScript are linted with biome.
C is linted with clang-format.
To lint the code, run:
prek -a
You can have the linter automatically run whenever you commit by running
pip install prek
prek install
and this can later be disabled with
prek uninstall
If you dont lint your code, certain lint errors will be fixed automatically by
pre-commit.ci which will push fixes to your branch. If you want to push more
commits, you will either have to pull in the remote changes or force push.
| Web Proxy Viewer | New URL | Original Page |