- 
                Notifications
    
You must be signed in to change notification settings  - Fork 247
 
Description
Sorry if this issue is a bit out of scope for pytest-xdist, however as this project deals with running pytest remotely and results serialization I though there might be some intersection.
I'm trying to run unit tests with Pytest in a WebAssembly environment as part of the pyodide project. For instance to run the numpy test suite, the test would conceptually look as follows,
test_numpy_suite.py
def test_numpy_suite(selenium):
    selenium.load_package(['numpy', 'pytest', 'nose'])
    exit_code = selenium.run(
       """
       import pytest
       pytest.run(['--pyargs', 'numpy'])
       """)
    assert exit_code == 0
    print(selenium.logs)  # stdout with test results would be herewhich would be run with,
pytest -s test_numpy_suite.py(a more concrete example can be found here). The selenium fixture is not created with pytest-selenium, but it's close enough; the main points is that it yields a browser instance.
So we have two pytest instances, one in the host system (master in pytest-xdist terminology), and one running in WebAssembly (worker). Currently the output of the second one, are just printed at stdout of the host system. Ideally I would like to do something like,
pytest --wasm --pyargs numpy   # e.g. assuming pytest-xdist is installed on hostin which the master pytest instance passes the argument to the worker, that does test collection and execution, and sends the results back to the master. (If I understand correctly pytest-xdist works the other way around with master doing collection by default).
Another point I was wondering is about the communication between the two instances. After superficially reading the execnet docs, from what I understood it communicates via "gateways", but the current limitation of the WebAssembly environment is that it's not possible to create new processes, threads, open sockets (or use SSH), and I am not sure what would be the best workaround. It is possible to send Python basic objects (in the main thread) from the WASM environment back to the host python process, though. Or create some kind of HTTP server on the master to which the the worker would connect to.
Any suggestions would be very much appreciated! For more context see e.g. pyodide/pyodide#69