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

ModuleNotFoundError: No module named 'py.xml'; 'py' is not a package #692

Closed
petersilva opened this issue Jun 5, 2023 · 7 comments
Closed
Labels
bug Something isn't working Developer not a problem, more of a note to self for devs about work to do. v3only Only affects v3 branches. v3 issue deferred to or affects version 3

Comments

@petersilva
Copy link
Contributor

petersilva commented Jun 5, 2023

Trying to run unit tesst from the command line as indicated in the instructions.

installed requirements.txt as indicated.
running unit tests as specified:

fractal% pytest tests
Traceback (most recent call last):
  File "/home/peter/.local/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "/home/peter/.local/lib/python3.10/site-packages/_pytest/config/__init__.py", line 189, in console_main
    code = main()
  File "/home/peter/.local/lib/python3.10/site-packages/_pytest/config/__init__.py", line 147, in main
    config = _prepareconfig(args, plugins)
  File "/home/peter/.local/lib/python3.10/site-packages/_pytest/config/__init__.py", line 328, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
  File "/home/peter/.local/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/home/peter/.local/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/home/peter/.local/lib/python3.10/site-packages/pluggy/_callers.py", line 55, in _multicall
    gen.send(outcome)
  File "/home/peter/.local/lib/python3.10/site-packages/_pytest/helpconfig.py", line 103, in pytest_cmdline_parse
    config: Config = outcome.get_result()
  File "/home/peter/.local/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/peter/.local/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/home/peter/.local/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1067, in pytest_cmdline_parse
    self.parse(args)
  File "/home/peter/.local/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1354, in parse
    self._preparse(args, addopts=addopts)
  File "/home/peter/.local/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1237, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/home/peter/.local/lib/python3.10/site-packages/pluggy/_manager.py", line 287, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "/home/peter/.local/lib/python3.10/site-packages/_pytest/assertion/rewrite.py", line 172, in exec_module
    exec(co, module.__dict__)
  File "/home/peter/.local/lib/python3.10/site-packages/pytest_html/plugin.py", line 9, in <module>
    from .html_report import HTMLReport
  File "/home/peter/.local/lib/python3.10/site-packages/_pytest/assertion/rewrite.py", line 172, in exec_module
    exec(co, module.__dict__)
  File "/home/peter/.local/lib/python3.10/site-packages/pytest_html/html_report.py", line 11, in <module>
    from py.xml import html
ModuleNotFoundError: No module named 'py.xml'; 'py' is not a package
fractal% python3 -V
Python 3.10.6
fractal% 

This is on ubuntu 22.04 workstation.

@petersilva
Copy link
Contributor Author

@gcglinton any ideas?

@petersilva petersilva added bug Something isn't working Developer not a problem, more of a note to self for devs about work to do. v3 issue deferred to or affects version 3 v3only Only affects v3 branches. labels Jun 5, 2023
@gcglinton
Copy link
Contributor

I have no ideas.. I just followed my own directions on a clean Ubuntu 22.04 WSL instance, and I'm able to run the tests no problem.

Python packages:

greg@SSC-23395604957:~/sr3$ pip list installed --local
Package                Version       Editable project location
---------------------- ------------- -------------------------
appdirs                1.4.4
async-timeout          4.0.2
bcrypt                 4.0.1
blinker                1.4
cffi                   1.15.1
colorama               0.4.6
command-not-found      0.3
coverage               7.2.7
cryptography           3.4.8
dbus-python            1.2.18
distro                 1.7.0
distro-info            1.1build1
exceptiongroup         1.1.1
fakeredis              2.13.0
future-fstrings        1.2.0
httplib2               0.20.2
humanfriendly          10.0
humanize               4.6.0
importlib-metadata     4.6.4
iniconfig              2.0.0
jeepney                0.7.1
jsonpickle             3.0.1
keyring                23.5.0
launchpadlib           1.10.16
lazr.restfulclient     0.14.4
lazr.uri               1.0.6
lupa                   1.14.1
metpx-sr3              3.0.40        /home/greg/sr3
more-itertools         8.10.0
netifaces              0.11.0
networkx               3.1
oauthlib               3.2.0
packaging              23.1
paramiko               3.2.0
pip                    23.1.2
pluggy                 1.0.0
psutil                 5.9.5
py                     1.11.0
pycparser              2.21
PyGObject              3.42.1
PyJWT                  2.3.0
PyNaCl                 1.5.0
pyparsing              2.4.7
pytest                 7.3.1
pytest-bug             1.2.0
pytest-cov             4.1.0
pytest-depends         1.0.1
pytest-html            3.2.0
pytest-metadata        3.0.0
python-apt             2.4.0+ubuntu1
python-redis-lock      4.0.0
PyYAML                 5.4.1
ubuntu-advantage-tools 8001
unattended-upgrades    0.1
wadllib                1.3.6
watchdog               3.0.0
wheel                  0.37.1
zipp                   1.0.0

Test run output, with all plugins enabled.

greg@SSC-23395604957:~/sr3$ pytest tests --html=tests/report.html --self-contained-html \
--cov-config=tests/.coveragerc --cov=sarracenia --cov-report=xml --cov-report=html \
--junitxml=tests/junit/test-results.xml
============================================================= test session starts ==============================================================
platform linux -- Python 3.10.6, pytest-7.3.1, pluggy-1.0.0
rootdir: /home/greg/sr3/tests
configfile: pytest.ini
plugins: bug-1.2.0, metadata-3.0.0, depends-1.0.1, html-3.2.0, cov-4.1.0
collected 50 items

tests/sarracenia/diskqueue_test.py ................                                                                                      [ 32%]
tests/sarracenia/redisqueue_test.py ...............s..                                                                                   [ 68%]
tests/sarracenia/flowcb/retry_test.py ....                                                                                               [ 76%]
tests/sarracenia/flowcb/nodupe/__init___test.py .......                                                                                  [ 90%]
tests/sarracenia/flowcb/retry_test.py b....                                                                                              [100%]

--------------------------------------- generated xml file: /home/greg/sr3/tests/junit/test-results.xml ----------------------------------------
--------------------------------------------------------------- Bugs skipped: 1 ---------------------------------------------------------------- 
----------------------------------------- generated html file: file:///home/greg/sr3/tests/report.html -----------------------------------------
---------- coverage: platform linux, python 3.10.6-final-0 -----------
Coverage HTML written to dir tests/coverage/html_report
Coverage XML written to file tests/coverage/coverage.xml

======================================================== 48 passed, 2 skipped in 3.61s =========================================================

I did have to restart my session after installing the test requirements, as ./loca/bin (which is where pytest lives) didn't show up in my $PATH. I suspect that won't have been an issue for you though.

@petersilva
Copy link
Contributor Author

something weird with my environment.... ? I will try in a vm.

@petersilva
Copy link
Contributor Author

works in a vm...weird...

@petersilva
Copy link
Contributor Author

for what it's worth I found a report on the internetl... if I downgrade pytest==7.1.0 it works fine, but any later version fails. when I do run the tests with 7.1.0 this happens:

fractal% pytest tests
======================================================================== test session starts ========================================================================
platform linux -- Python 3.10.6, pytest-7.1.0, pluggy-1.0.0
rootdir: /home/peter/Sarracenia/sr3/tests, configfile: pytest.ini
plugins: metadata-3.0.0, depends-1.0.1, html-3.2.0, bug-1.2.0, anyio-3.6.2, cov-4.1.0
collected 96 items                                                                                                                                                  

tests/sarracenia/__init___test.py ......E..E..                                                                                                                [ 12%]
tests/sarracenia/diskqueue_test.py ................                                                                                                           [ 29%]
tests/sarracenia/redisqueue_test.py .................                                                                                                         [ 46%]
tests/sarracenia/flowcb/nodupe/data_test.py .                                                                                                                 [ 47%]
tests/sarracenia/flowcb/nodupe/disk_test.py .....                                                                                                             [ 53%]
tests/sarracenia/flowcb/nodupe/name_test.py .                                                                                                                 [ 54%]
tests/sarracenia/flowcb/nodupe/redis_test.py .....                                                                                                            [ 59%]
tests/sarracenia/__init___test.py E...                                                                                                                        [ 63%]
tests/sarracenia/flowcb/retry_test.py b........                                                                                                               [ 72%]
tests/sarracenia/flowcb/nodupe/disk_test.py ...                                                                                                               [ 76%]
tests/sarracenia/flowcb/nodupe/redis_test.py ...                                                                                                              [ 79%]
tests/sarracenia/__init___test.py ..                                                                                                                          [ 81%]
tests/sarracenia/flowcb/nodupe/disk_test.py .............                                                                                                     [ 94%]
tests/sarracenia/flowcb/nodupe/nodupe_test.py .....                                                                                                           [100%]

============================================================================== ERRORS ===============================================================================
_______________________________________________________ ERROR at setup of Test_Message.test___computeIdentity _______________________________________________________
file /home/peter/Sarracenia/sr3/tests/sarracenia/__init___test.py, line 130
      def test___computeIdentity(self, tmp_path, mocker, caplog):
E       fixture 'mocker' not found
>       available fixtures: anyio_backend, anyio_backend_name, anyio_backend_options, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, doctest_namespace, extra, include_metadata_in_junit_xml, message, metadata, monkeypatch, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/home/peter/Sarracenia/sr3/tests/sarracenia/__init___test.py:130
__________________________________________________________ ERROR at setup of Test_Message.test_getContent ___________________________________________________________
file /home/peter/Sarracenia/sr3/tests/sarracenia/__init___test.py, line 456
      def test_getContent(self, mocker):
E       fixture 'mocker' not found
>       available fixtures: anyio_backend, anyio_backend_name, anyio_backend_options, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, doctest_namespace, extra, include_metadata_in_junit_xml, message, metadata, monkeypatch, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/home/peter/Sarracenia/sr3/tests/sarracenia/__init___test.py:456
__________________________________________________________ ERROR at setup of Test_Message.test_updatePaths __________________________________________________________
file /home/peter/Sarracenia/sr3/tests/sarracenia/__init___test.py, line 344
      @pytest.mark.depends(on=['sarracenia/__init___test.py::test_baseUrlParse'])
      def test_updatePaths(self, tmp_path, mocker):
E       fixture 'mocker' not found
>       available fixtures: anyio_backend, anyio_backend_name, anyio_backend_options, cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, doctest_namespace, extra, include_metadata_in_junit_xml, message, metadata, monkeypatch, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/home/peter/Sarracenia/sr3/tests/sarracenia/__init___test.py:344
-------------------------------------------------------------------------- Bugs skipped: 1 --------------------------------------------------------------------------
====================================================================== short test summary info ======================================================================
ERROR tests/sarracenia/__init___test.py::Test_Message::test___computeIdentity
ERROR tests/sarracenia/__init___test.py::Test_Message::test_getContent
ERROR tests/sarracenia/__init___test.py::Test_Message::test_updatePaths
============================================================== 92 passed, 1 skipped, 3 errors in 2.29s ==============================================================

is that normal?

@petersilva
Copy link
Contributor Author

never mind... I got it to succeed by installing the requirements completely (which added mock), and then downgrading pytests. very strange, but is working.

@petersilva
Copy link
Contributor Author

pytest-dev/pytest#10428

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Developer not a problem, more of a note to self for devs about work to do. v3only Only affects v3 branches. v3 issue deferred to or affects version 3
Projects
None yet
Development

No branches or pull requests

2 participants