Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. pytest-qt Fatal Python error: Aborted Python 3.7.16, pytest-7.2.1, pip
Qt 6.11 is out! See what's new in the release blog

pytest-qt Fatal Python error: Aborted Python 3.7.16, pytest-7.2.1, pip

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 1 Posters 756 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Captain Haddock
    wrote on last edited by
    #1

    I have a very simple application that runs fine from the command line:

    python3 MyApp.py

    import sys
    
    from PyQt5.QtGui import QFont
    from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QVBoxLayout
    
    
    class MyApp(QWidget):
    
        def __init__(self):
            super().__init__()
    
            self.text_label = QLabel()
            self.text_label.setText("Hello World!")
            self.text_label.setFont(QFont('Arial', 20))
    
            self.button = QPushButton("Fancy Button")
            self.button.setFont(QFont('Arial', 14))
            self.button.clicked.connect(lambda: self.text_label.setText("Changed!"))
    
            self.setGeometry(50, 50, 300, 200)
            self.setWindowTitle("PyQt5 Example")
    
            self.layout = QVBoxLayout(self)
            self.layout.addWidget(self.text_label)
            self.layout.addWidget(self.button)
            self.setLayout(self.layout)
    
    
    if __name__ == '__main__':
        app = QApplication(sys.argv)
        ex = MyApp()
        ex.show()
        sys.exit(app.exec_())
    
    

    I then create a simple test (test_MyApp.py):

    import pytest
    
    from PyQt5 import QtCore
    
    import MyApp
    
    
    @pytest.fixture
    def app(qtbot):
        test_hello_app = MyApp.MyApp()
        qtbot.addWidget(test_hello_app)
    
        return test_hello_app
    
    
    def test_label(app):
        assert app.text_label.text() == "Hello World!"
    
    
    def test_label_after_click(app, qtbot):
        qtbot.mouseClick(app.button, QtCore.Qt.LeftButton)
        assert app.text_label.text() == "Changed!"
    

    When I run the test from the command line I get a fatal python error (see below) .. anyone have an idea what is wrong?

    $ pytest test_MyApp.py
    =============================================================================== test session starts ================================================================================
    platform linux -- Python 3.7.16, pytest-7.2.1, pluggy-1.0.0
    PyQt6 6.4.0 -- Qt runtime 6.4.2 -- Qt compiled 6.4.0
    rootdir: /home/david/InsightSurgical/BitBucket/test
    plugins: qt-4.2.0, mock-3.10.0
    collected 2 items                                                                                                                                                                  
    
    test_MyApp.py Fatal Python error: Aborted
    
    Current thread 0x00007f665a12e000 (most recent call first):
      File "/home/david/InsightSurgical/BitBucket/test/MyApp.py", line 10 in __init__
      File "/home/david/InsightSurgical/BitBucket/test/test_MyApp.py", line 10 in app
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/fixtures.py", line 908 in call_fixture_func
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/fixtures.py", line 1129 in pytest_fixture_setup
      File "/home/david/.local/lib/python3.7/site-packages/pluggy/_callers.py", line 39 in _multicall
      File "/home/david/.local/lib/python3.7/site-packages/pluggy/_manager.py", line 80 in _hookexec
      File "/home/david/.local/lib/python3.7/site-packages/pluggy/_hooks.py", line 265 in __call__
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/fixtures.py", line 1075 in execute
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/fixtures.py", line 677 in _compute_fixture_value
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/fixtures.py", line 591 in _get_active_fixturedef
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/fixtures.py", line 569 in getfixturevalue
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/fixtures.py", line 550 in _fillfixtures
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/python.py", line 1792 in setup
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/runner.py", line 492 in setup
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/runner.py", line 155 in pytest_runtest_setup
      File "/home/david/.local/lib/python3.7/site-packages/pluggy/_callers.py", line 39 in _multicall
      File "/home/david/.local/lib/python3.7/site-packages/pluggy/_manager.py", line 80 in _hookexec
      File "/home/david/.local/lib/python3.7/site-packages/pluggy/_hooks.py", line 265 in __call__
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/runner.py", line 260 in <lambda>
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/runner.py", line 339 in from_call
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/runner.py", line 260 in call_runtest_hook
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/runner.py", line 220 in call_and_report
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/runner.py", line 125 in runtestprotocol
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/runner.py", line 112 in pytest_runtest_protocol
      File "/home/david/.local/lib/python3.7/site-packages/pluggy/_callers.py", line 39 in _multicall
      File "/home/david/.local/lib/python3.7/site-packages/pluggy/_manager.py", line 80 in _hookexec
      File "/home/david/.local/lib/python3.7/site-packages/pluggy/_hooks.py", line 265 in __call__
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/main.py", line 349 in pytest_runtestloop
      File "/home/david/.local/lib/python3.7/site-packages/pluggy/_callers.py", line 39 in _multicall
      File "/home/david/.local/lib/python3.7/site-packages/pluggy/_manager.py", line 80 in _hookexec
      File "/home/david/.local/lib/python3.7/site-packages/pluggy/_hooks.py", line 265 in __call__
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/main.py", line 324 in _main
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/main.py", line 270 in wrap_session
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/main.py", line 317 in pytest_cmdline_main
      File "/home/david/.local/lib/python3.7/site-packages/pluggy/_callers.py", line 39 in _multicall
      File "/home/david/.local/lib/python3.7/site-packages/pluggy/_manager.py", line 80 in _hookexec
      File "/home/david/.local/lib/python3.7/site-packages/pluggy/_hooks.py", line 265 in __call__
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/config/__init__.py", line 168 in main
      File "/home/david/.local/lib/python3.7/site-packages/_pytest/config/__init__.py", line 190 in console_main
      File "/home/david/.local/bin/pytest", line 8 in <module>
    Aborted (core dumped)
    
    
    1 Reply Last reply
    0
    • C Offline
      C Offline
      Captain Haddock
      wrote on last edited by
      #2

      Could it be anything to do with the PyQt6 line in the error? The app is using PyQt5, but I do have PyQt6 installed on my system.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Captain Haddock
        wrote on last edited by
        #3

        Ah that was it. I removed PyQt6 from my system and issue resolved!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved