Remove QApplication.instance() deleteLater call

the test_signalproxy.py had a fixture for the QApplication instance,
only problem is at the end of each use of the fixture, it would mark
the application instance for deletion, which is most definitely not what
we want
This commit is contained in:
Ogi Moore 2021-05-28 00:34:29 -07:00
parent a6971c768d
commit 0160de22fb

View File

@ -1,7 +1,7 @@
import sys import sys
import pytest import pytest
from pyqtgraph.Qt import QtCore, QtGui, QT_LIB, PYSIDE from pyqtgraph.Qt import QtCore, QtGui, QT_LIB, mkQApp
from pyqtgraph import SignalProxy from pyqtgraph import SignalProxy
@ -24,13 +24,11 @@ class Receiver(QtCore.QObject):
@pytest.fixture @pytest.fixture
def qapp(): def qapp():
app = QtGui.QApplication.instance() app = mkQApp()
if app is None: if app is None:
app = QtGui.QApplication(sys.argv) app = QtGui.QApplication(sys.argv)
yield app yield app
app.processEvents(QtCore.QEventLoop.AllEvents, 100) app.processEvents(QtCore.QEventLoop.AllEvents, 100)
app.deleteLater()
def test_signal_proxy_slot(qapp): def test_signal_proxy_slot(qapp):
@ -50,13 +48,8 @@ def test_signal_proxy_slot(qapp):
qapp.processEvents(QtCore.QEventLoop.AllEvents, 10) qapp.processEvents(QtCore.QEventLoop.AllEvents, 10)
assert receiver.counter > 0 assert receiver.counter > 0
del proxy
del sender
del receiver
@pytest.mark.skipif(QT_LIB == PYSIDE and sys.version_info < (2, 8),
reason="Crashing on PySide and Python 2.7")
def test_signal_proxy_disconnect_slot(qapp): def test_signal_proxy_disconnect_slot(qapp):
"""Test the disconnect of SignalProxy with `signal` and `slot`""" """Test the disconnect of SignalProxy with `signal` and `slot`"""
sender = Sender(parent=qapp) sender = Sender(parent=qapp)
@ -80,10 +73,6 @@ def test_signal_proxy_disconnect_slot(qapp):
assert receiver.counter == 0 assert receiver.counter == 0
del proxy
del sender
del receiver
def test_signal_proxy_no_slot_start(qapp): def test_signal_proxy_no_slot_start(qapp):
"""Test the connect mode of SignalProxy without slot at start`""" """Test the connect mode of SignalProxy without slot at start`"""
@ -113,10 +102,6 @@ def test_signal_proxy_no_slot_start(qapp):
with pytest.raises(AssertionError): with pytest.raises(AssertionError):
proxy.connectSlot(receiver.slotReceive) proxy.connectSlot(receiver.slotReceive)
del proxy
del sender
del receiver
def test_signal_proxy_slot_block(qapp): def test_signal_proxy_slot_block(qapp):
"""Test the block mode of SignalProxy with `signal` and `slot`""" """Test the block mode of SignalProxy with `signal` and `slot`"""
@ -144,7 +129,3 @@ def test_signal_proxy_slot_block(qapp):
qapp.processEvents(QtCore.QEventLoop.AllEvents, 10) qapp.processEvents(QtCore.QEventLoop.AllEvents, 10)
assert receiver.counter > 0 assert receiver.counter > 0
del proxy
del sender
del receiver