You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My code to be tested (not the actual test code itself), is not on Pyodide's filesystem in the browser. I was expecting to see (using my example reproduction of the problem), my_module.py somewhere in the filesystem so it can be imported in the test module.
I think the exit code is because node_tree_id simply doesn't appear valid given the context in which pytest is run. There appears to be (as mentioned in this function's comments) a test_files base folder which means that the specified test is never found and....
If I hard code a replacement for node_tree_id to the absolute path to the test directory (i.e. testfiles/tests) then I get this XML result, which includes the ModuleNotFoundError because the code-to-be-tested hasn't been copied over:
<?xml version="1.0" encoding="utf-8"?>
<testsuites>
<testsuitename="pytest"errors="1"failures="0"skipped="0"tests="1"time="0.197"timestamp="2023-03-09T14:08:39.361000"hostname="emscripten">
<testcaseclassname=""name="test_files.tests.test_my_module"time="0.000">
<errormessage="collection failure">ImportError while importing test module \'/home/pyodide/test_files/tests/test_my_module.py\'.\nHint: make sure your test modules/packages have valid Python names.\nTraceback:\n/lib/python3.10/importlib/__init__.py:126: in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\ntest_files/tests/test_my_module.py:1: in <module>\n import my_module\nE ModuleNotFoundError: No module named \'my_module\'</error>
</testcase>
</testsuite>
</testsuites>
Not sure what to suggest - but something is definitely amiss: only the test module is copied over, and it's not referenced properly when calling pytest.main is the TL;DR.
Activity
ntoll commentedon Mar 9, 2023
I've spent some more time digging into this problem and focussed on this function.
As far as I can tell there are several problems:
my_module.pysomewhere in the filesystem so it can be imported in the test module.pytest.mainis4- i.e. pytest command line usage errornode_tree_idsimply doesn't appear valid given the context in whichpytestis run. There appears to be (as mentioned in this function's comments) atest_filesbase folder which means that the specified test is never found and....node_tree_idto the absolute path to the test directory (i.e.testfiles/tests) then I get this XML result, which includes the ModuleNotFoundError because the code-to-be-tested hasn't been copied over:Not sure what to suggest - but something is definitely amiss: only the test module is copied over, and it's not referenced properly when calling
pytest.mainis the TL;DR.hoodmane commentedon Mar 9, 2023
I guess the solution for now is to make a wheel.
ntoll commentedon Mar 9, 2023
🤣 yeah ☸️ 👍
All part of the fun.
ntoll commentedon Mar 9, 2023
Make a wheel (and then document / script the process)
hoodmane commentedon Mar 9, 2023
It would be great to fix pytest-pyodide so that it is not required to build a wheel for pure Python libs though.