Closed hakonhagland closed 1 year ago
Segmentation fault (core dumped)
I ran pytest
with gdb to get a backtrace. The problem seems to be in the destructor ~QGuiApplication()
. Here is a screen shot of the topmost frames:
Qt does not support creating multiple QApplications in the same process. pytest-qt creates one for you when you use qtbot
, which is why this doesn't work. I don't think there's anything pytest-qt could or should do about this.
pytest-qt creates one for you when you use qtbot
@The-Compiler Thanks! This solved my issue!
I don't think there's anything pytest-qt could or should do about this.
I suggest maybe updating the docs? See PR #505 for an example that could reduce confusion for beginners.
Sorry to question again as I run through this issue as well. Interesting point is, that all my test went fine on PyQt5 (without segfault) and the issue started when moving to PyQt6. There was no change in using qtBot or generation a QApplication. Any ideas ? Many thanks in advance. Michel
Edit 2: I run the same test Suite on MacOS and Windows without any problems...
Here the segfault: It's the access to app.setTitel in line 78
tests/unit_tests/base/test_tpool.py ...Fatal Python error: Aborted
Current thread 0x00007f9a5732a740 (most recent call first):
File "/opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/site-packages/pytestqt/plugin.py", line 76 in qapp
File "/opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/site-packages/_pytest/fixtures.py", line 932 in call_fixture_func
File "/opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/site-packages/_pytest/fixtures.py", line 1126 in pytest_fixture_setup
File "/opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/site-packages/pluggy/_callers.py", line 77 in _multicall
Extension modules: PyQt6.QtCore, PyQt6.QtGui, PyQt6.QtWidgets, PyQt6.QtTest, zstandard.backend_c, charset_normalizer.md, numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, PyQt6.QtNetwork, erfa.ufunc (total: 21)
Aborted (core dumped)
Error: Process completed with exit code 134.
I am on Ubuntu 22.04, using Poetry, Python 3.10 and PyQt6. When I run a test with pytest using the
qtbot
fixture I get a segmentation fault. If I remove theqtbot
fixture from the test file, it works fine. Here is a minimal example (my real test case is more complicated):Note: this question was first asked on stackoverflow.com