giampaolo / psutil

Cross-platform lib for process and system monitoring in Python
BSD 3-Clause "New" or "Revised" License
10.25k stars 1.38k forks source link

6.1.0: running self tests #2465

Open 0-wiz-0 opened 2 hours ago

0-wiz-0 commented 2 hours ago

In 6.1.0 the test system was switched from unittest to pytest. I've updated the package in pkgsrc using the pypi source distfile, but I can't run the tests any longer. Using the command line from HISTORY.rst:

/usr/pkg/bin/python3.12 -m psutil.tests
/usr/pkg/bin/python3.12: Error while finding module specification for 'psutil.tests' (ImportError: cannot import name '_psutil_bsd' from partially initialized module 'psutil' (most likely due to a circular import) (/scratch/sysutils/py-psutil/work/psutil-6.1.0/psutil/__init__.py))

Using pytest directly, from the top level:

====================================================================================== test session starts =======================================================================================
platform netbsd10 -- Python 3.12.7, pytest-8.3.3, pluggy-1.5.0
rootdir: /scratch/sysutils/py-psutil/work/psutil-6.1.0
configfile: pyproject.toml
collected 0 items / 16 errors

============================================================================================= ERRORS =============================================================================================
___________________________________________________________________________ ERROR collecting psutil/tests/test_aix.py ____________________________________________________________________________
ImportError while importing test module '/scratch/sysutils/py-psutil/work/psutil-6.1.0/psutil/tests/test_aix.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/pkg/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
psutil/__init__.py:127: in <module>
    from . import _psbsd as _psplatform
psutil/_psbsd.py:17: in <module>
    from . import _psutil_bsd as cext
E   ImportError: cannot import name '_psutil_bsd' from partially initialized module 'psutil' (most likely due to a circular import) (/scratch/sysutils/py-psutil/work/psutil-6.1.0/psutil/__init__
.py)
___________________________________________________________________________ ERROR collecting psutil/tests/test_bsd.py ____________________________________________________________________________
...

It doesn't matter if I install the package first or not. In case it matters, in pkgsrc, the package is built using:

/usr/pkg/bin/python3.12  -m build --wheel --skip-dependency-check --no-isolation

What is the proper way to run the tests now? Thanks.

giampaolo commented 2 hours ago

Hi Thomas. The error looks unrelated with pytest. Usually that means a broken psutil installation (e.g. after a psutil upgrade). You can try:

make clean uninstall install
0-wiz-0 commented 2 hours ago

Hi Giampaolo! No, that's not it, the tests are run in an empty sandbox, there is no psutil installed there.

giampaolo commented 2 hours ago

Can you import psutil? I mean python3 -c "import psutil"?

0-wiz-0 commented 2 hours ago

If I install psutil (which doesn't make a difference for the test) then yes:

# python3.12 -c "import psutil"
#