Closed TonyXTYan closed 4 days ago
Hi @TonyXTYan,
I see tests/test_icons_pt.py
and tests/test_icons_ut.py
, but the log shows:
____________________ ERROR collecting tests/test_icons.py _____________________
ImportError while importing test module 'D:\a\HeLab\HeLab\tests\test_icons.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\importlib\__init__.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests\test_icons.py:6: in <module>
from PyQt6.QtGui import QIcon
E ImportError: DLL load failed while importing QtCore: The specified procedure could not be found.
I assume some step before pytest runs is renaming test_icons_pt.py
(pt=pytest) to test_icons.py
?
There's an app
fixture which caught my eye:
pytest-qt
has its own qapp
fixture which is responsible for initializing QApplication
, perhaps there's some conflict in there. Change your app
fixture to:
@pytest.fixture(scope="session", autouse=True)
def init_icons(qapp):
StatusIcons.initialise_icons()
return qapp
And see if that helps.
If not, is there anything special that is being done by your test suite to initialize Qt?
Hi @nicoddemus,
I changed the file names and made some squashes since I posted here. Apologies for the confusion.
Changing the @pytest.fixture
fixed the problem. Thank you so much for helping.
Hi pytest dev,
When I have
pytest-qt
in myrequirements.tet
, and runpytest
on github hosted action runners, it will fail for all python versions on windows, whereas the test will pass on macos and ubuntu.This is the run with
pytest-qt
included: https://github.com/TonyXTYan/HeLab/actions/runs/11644144376This is the run with
pytest-qt
removed: https://github.com/TonyXTYan/HeLab/actions/runs/11644168485The only difference between those two commits the one line of
pytest-qt
inrequirements.txt
.Attached is the full console (error) message from
>pytest -v
. error message.txt