pyodide/pytest-pyodide

Copy source into pyodide environment

koenvo opened this issue · 4 comments

When running the tests of pyodide-http I occasionally forget to first build the wheel. It would be very convenient when the current context is copied pyodide environment before starting the test.

This could be an additional argument to run_in_pyodide like source_packages. Or maybe even more generic: copy directories to the pyodide environment before execution.

Curious what you think about it.

Sounds like there is some overlap here with what I have been trying to do with my command line test runner, so that tests can be run like python -m pytest and that invokes a Pyodide Python to run the tests. The command line runner uses the Emscripten NodeFS to join the Pyodide file system to the host file system. Then it uses a virtual environment and other stuff residing on the native file system.

Unfortunately it is not clear how to do this in selenium. Chrome's files system access API could work, but it is not clear how to use it in selenium @ryanking13 has made some useful efforts in this direction but he didn't work out yet how to do the dialog window interaction needed to use it in tests. If we worked that out, maybe we could get a command line test runner that also works in Chrome.

Anyways something like what you describe could be a useful half-measure.

Ah yes nodefs should do the trick. Is your code available somewhere? Curious to the implementation details!

In a real browser it seems pretty hard. “This interface will not grant you access to the users' filesystem. Instead, you will have a "virtual drive" within the browser sandbox” https://developer.mozilla.org/en-US/docs/Web/API/FileSystem

Or maybe it’s possible: https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API

Let me see if I’m able to come up with a POC

rth commented

copy directories to the pyodide environment before execution.

There is also an ongoing PR in #62 to do this