I'm new to pytest and I'm having trouble trying to run one of my test files. I'm getting the following output:
================================================== test session starts ==================================================
platform linux -- Python 3.7.6, pytest-5.3.5, py-1.8.1, pluggy-0.13.1 -- /home/jarel/anaconda3/bin/python
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/jarel/workspace/spyder/rpgland/.hypothesis/examples')
PyQt5 5.9.2 -- Qt runtime 5.9.7 -- Qt compiled 5.9.6
rootdir: /home/jarel/workspace/spyder/rpgland
plugins: astropy-header-0.1.2, cov-2.8.1, openfiles-0.4.0, arraydiff-0.3, hypothesis-5.5.4, qt-3.3.0, doctestplus-0.5.0, remotedata-0.3.2
collected 1 item
rpgland/test_character_window.py::test_init_character Fatal Python error: Aborted
Current thread 0x00007fb5b7229740 (most recent call first):
File "/home/jarel/workspace/spyder/rpgland/rpgland/view/character_info_window.py", line 9 in __init__
File "/home/jarel/workspace/spyder/rpgland/rpgland/test_character_window.py", line 20 in gui
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/fixtures.py", line 788 in call_fixture_func
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/fixtures.py", line 958 in pytest_fixture_setup
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/callers.py", line 187 in _multicall
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/manager.py", line 87 in <lambda>
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/manager.py", line 93 in _hookexec
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/hooks.py", line 286 in __call__
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/fixtures.py", line 909 in execute
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/fixtures.py", line 580 in _compute_fixture_value
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/fixtures.py", line 499 in _get_active_fixturedef
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/fixtures.py", line 483 in getfixturevalue
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/fixtures.py", line 473 in _fillfixtures
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/fixtures.py", line 294 in fillfixtures
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/python.py", line 1449 in setup
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/runner.py", line 370 in prepare
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/runner.py", line 122 in pytest_runtest_setup
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/callers.py", line 187 in _multicall
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/manager.py", line 87 in <lambda>
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/manager.py", line 93 in _hookexec
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/hooks.py", line 286 in __call__
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/runner.py", line 210 in <lambda>
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/runner.py", line 237 in from_call
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/runner.py", line 210 in call_runtest_hook
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/runner.py", line 185 in call_and_report
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/runner.py", line 93 in runtestprotocol
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/runner.py", line 84 in pytest_runtest_protocol
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/callers.py", line 187 in _multicall
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/manager.py", line 87 in <lambda>
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/manager.py", line 93 in _hookexec
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/hooks.py", line 286 in __call__
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/main.py", line 271 in pytest_runtestloop
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/callers.py", line 187 in _multicall
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/manager.py", line 87 in <lambda>
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/manager.py", line 93 in _hookexec
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/hooks.py", line 286 in __call__
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/main.py", line 247 in _main
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/main.py", line 197 in wrap_session
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/main.py", line 240 in pytest_cmdline_main
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/callers.py", line 187 in _multicall
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/manager.py", line 87 in <lambda>
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/manager.py", line 93 in _hookexec
File "/home/jarel/anaconda3/lib/python3.7/site-packages/pluggy/hooks.py", line 286 in __call__
File "/home/jarel/anaconda3/lib/python3.7/site-packages/_pytest/config/__init__.py", line 93 in main
File "/home/jarel/anaconda3/bin/pytest", line 11 in <module>
Aborted (core dumped)
The line it looks to be choking on is a call to "super" within the __init__() function of the CharacterInfowWindow class (subclass of QtWidgets.QMainWindow) within the character_info_window module. Any ideas on what could be the problem?
I had this issue today as well. The solution for me was to create a pytest.ini file in my tests directory and include this in it.
[pytest]
qt_api=pyqt5
From https://github.com/pytest-dev/pytest-qt
To force a particular API, set the configuration variable qt_api in your pytest.ini file to pyqt5 or pyside2
Once I set the qt_api in the pytest.ini the tests ran without any issues