Skip to content
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 non-pyodide tests in pyodide automatically? #58

Closed
joemarshall opened this issue Nov 2, 2022 · 5 comments
Closed

Support running non-pyodide tests in pyodide automatically? #58

joemarshall opened this issue Nov 2, 2022 · 5 comments

Comments

@joemarshall
Copy link
Collaborator

Looking at porting libraries to work with webassembly, it would be nice to have a 'run the library tests in pyodide' option.

e.g. an option to pytest which instead of running all tests in pytest_pyodide and requiring e.g. selenium objects etc. it would instead install the package and run all tests found on a pyodide instance.

Otherwise I'm implementing separate test fixtures for pyodide tests, which essentially copy everything across to pyodide, import the package, then run the tests.

@ryanking13
Copy link
Member

I am not sure I understood your proposal correctly. If the package contains test files then if those can be run with pytest or unittest, you can run it with pytest and unittest APIs (example). Is this what you are looking for?

@joemarshall
Copy link
Collaborator Author

I guess that is kind of almost what I'm looking for. It would be nice to have an easy way to automate it though - for example take ultrajson ( https://github.com/ultrajson/ultrajson which I've got a PR for wasm compatibility in), it has a tests folder outside the module itself. In the CI it runs all tests. It would be nice to have an option in pytest-pyodide to spin up a pyodide instance, copy the tests folder across and call pytest in that. That way at least in theory, the only change needed to get pyodide added to CI would be to add the pytest-pyodide workflow to the CI.

I guess now I know pytest works inside pyodide, the functionality I'm looking for here is:

  1. An argument to copy a list of files or a folder across to the pyodide instance
  2. An argument to run pytest in the pyodide instance not locally.

@hoodmane
Copy link
Member

hoodmane commented Nov 3, 2022

This is related to my command line runner. The idea there is that you make a special virtual environment, install the dependencies, and then run python -m pytest and everything works as expected. See
https://github.com/hoodmane/numpy/blob/emscripten-ci/.github/workflows/emscripten.yml#L56-L66
in numpy/numpy#21895.

@joemarshall
Copy link
Collaborator Author

joemarshall commented Nov 7, 2022

Wow, I like that python runner. Any way to make it work as a browser test as well as node though? Or would it be easier to add code to pytest-pyodide to do the equivalent (e.g. add an extra tool script which copies things to the pyodide installation and runs pytest)

@rth
Copy link
Member

rth commented Dec 10, 2022

PR for this issue is in #62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants