pyodide/pytest-pyodide

`build-packages-no-numpy-dependents` Tests fail with "`ModuleNotFoundError. No module named ...`"

Opened this issue · 1 comments

The Circle CI tests test-packages-<browser>-no-numpy-dependents fail with the error:

=================================== FAILURES ===================================
_____________________________ test_peewee[chrome] ______________________________
/usr/local/lib/python3.11/site-packages/pytest_pyodide/decorator.py:107: in _decode
    raise ModuleNotFoundError(
E   ModuleNotFoundError: There was a problem with unpickling the return value/exception from your pyodide environment. This usually means the type of the return value does not exist in your host environment. The original message is: No module named 'peewee'.
---------------------------- Captured stdout setup -----------------------------
Spawning webserver at http://127.0.0.1:54469 (see logs in /tmp/tmp6kk1q8i1/http-server.log)
--------------------------- Captured stdout teardown ---------------------------
Loading peewee, cffi, pycparser, pytest, atomicwrites, attrs, six, more-itertools, pluggy, py, setuptools, distutils, pyparsing, iniconfig, exceptiongroup, tblib
Loaded atomicwrites, pycparser, six, attrs, more-itertools, pluggy, py, distutils, pyparsing, iniconfig, exceptiongroup, tblib, cffi, setuptools, pytest, peewee
pyodide.isPyProxy() is deprecated. Use `instanceof pyodide.ffi.PyProxy` instead.
------------ generated xml file: /root/repo/test-results/junit.xml -------------
============================= slowest 50 durations =============================
2.76s setup    packages/peewee/test_peewee.py::test_peewee[chrome]
1.31s call     packages/peewee/test_peewee.py::test_peewee[chrome]
0.22s teardown packages/peewee/test_peewee.py::test_peewee[chrome]
=========================== short test summary info ============================
FAILED peewee/test_peewee.py::peewee[chrome] - ModuleNotFoundError: There was a problem with unpickling the return value/exception from your pyodide environment. This usually means the type of the return value does not exist in your host environment. The original message is: No module named 'peewee'.
============================== 1 failed in 4.93s ===============================

This presently affects this pull request:

@hoodmane's suggestion from the above PR thread:

@ryanking13 we could probably update pytest_pyodide to try to create something with a sane repr/traceback when it fails to unpickle an error. Since it's pretty rare that people define exceptions with a custom reduce.

Thanks for opening the issue! It would definitely be nice to show some better traceback when unpickling fails.

For now, you can directly use the selenium fixture in your tests to prevent unpickle errors and see the actual error message.

For example, you can replace @run_in_pyodide decorator with:

@run_in_pyodide
def test_blah(selenium):
    do_some_test()
def test_blah(selenium):
    selenium.run(
    """
    do_some_test()
    """
    )