TST: use pyqtgraph.Qt to import Qt stuff

This commit is contained in:
Eric Dill 2015-07-18 09:38:34 -04:00
parent b6dae6c95b
commit c02dbe7679
6 changed files with 30 additions and 16 deletions

View File

@ -18,11 +18,11 @@ for frontend in frontends.keys():
except ImportError:
pass
@pytest.mark.parametrize(
"frontend, f", itertools.product(sorted(list(frontends.keys())), files))
def test_examples(frontend, f):
# Test the examples with whatever the current QT_LIB front
# end is
# Test the examples with all available front-ends
print('frontend = %s. f = %s' % (frontend, f))
if not frontends[frontend]:
pytest.skip('{} is not installed. Skipping tests'.format(frontend))

View File

@ -4,7 +4,7 @@ This module exists to smooth out some of the differences between PySide and PyQt
* Automatically import either PyQt4 or PySide depending on availability
* Allow to import QtCore/QtGui pyqtgraph.Qt without specifying which Qt wrapper
you want to use.
* Declare QtCore.Signal, .Slot in PyQt4
* Declare QtCore.Signal, .Slot in PyQt4
* Declare loadUiType function for Pyside
"""
@ -19,7 +19,7 @@ PYQT5 = 'PyQt5'
QT_LIB = None
## Automatically determine whether to use PyQt or PySide.
## Automatically determine whether to use PyQt or PySide.
## This is done by first checking to see whether one of the libraries
## is already imported. If not, then attempt to import PyQt4, then PySide.
libOrder = [PYQT4, PYSIDE, PYQT5]
@ -69,7 +69,7 @@ if QT_LIB == PYSIDE:
# Make a loadUiType function like PyQt has
# Credit:
# Credit:
# http://stackoverflow.com/questions/4442286/python-code-genration-with-pyside-uic/14195313#14195313
class StringIO(object):
@ -85,7 +85,15 @@ if QT_LIB == PYSIDE:
def loadUiType(uiFile):
"""
Pyside "loadUiType" command like PyQt4 has one, so we have to convert the ui file to py code in-memory first and then execute it in a special frame to retrieve the form_class.
Pyside "loadUiType" command like PyQt4 has one, so we have to convert
the ui file to py code in-memory first and then execute it in a
special frame to retrieve the form_class.
from stackoverflow: http://stackoverflow.com/a/14195313/3781327
seems like this might also be a legitimate solution, but I'm not sure
how to make PyQt4 and pyside look the same...
http://stackoverflow.com/a/8717832
"""
import pysideuic
import xml.etree.ElementTree as xml

View File

@ -3,7 +3,6 @@ import pyqtgraph as pg
import pytest
app = pg.mkQApp()
qtest = pg.Qt.QtTest.QTest
def assertMapping(vb, r1, r2):
assert vb.mapFromView(r1.topLeft()) == r2.topLeft()
@ -11,10 +10,14 @@ def assertMapping(vb, r1, r2):
assert vb.mapFromView(r1.topRight()) == r2.topRight()
assert vb.mapFromView(r1.bottomRight()) == r2.bottomRight()
# TODO fix this test!
@pytest.mark.skipif(True, reason=('unclear why test is failing. skipping until '
'someone has time to fix it'))
# @pytest.mark.skipif(True or pg.Qt.USE_PYSIDE,
# reason=('unclear why test is failing. skipping until '
# 'someone has time to fix it'))
@pytest.mark.skipif(pg.Qt.USE_PYSIDE, reason="pyside does not have qTest")
def test_ViewBox():
qtest = pg.Qt.QtTest.QTest
global app, win, vb
QRectF = pg.QtCore.QRectF

View File

@ -1,5 +1,6 @@
import gc
import weakref
import pytest
# try:
# import faulthandler
# faulthandler.enable()
@ -11,7 +12,7 @@ import numpy as np
import pyqtgraph as pg
app = pg.mkQApp()
@pytest.mark.skipif(pg.Qt.USE_PYSIDE, reason="pyside does not have qWait")
def test_dividebyzero():
import pyqtgraph as pg
im = pg.image(pg.np.random.normal(size=(100,100)))

View File

@ -1,5 +1,7 @@
import pyqtgraph as pg
import gc, os
import pytest
app = pg.mkQApp()
@ -11,7 +13,8 @@ def test_isQObjectAlive():
gc.collect()
assert not pg.Qt.isQObjectAlive(o2)
@pytest.mark.skipif(pg.Qt.USE_PYSIDE, reason='pysideuic does not appear to be '
'packaged with conda')
def test_loadUiType():
path = os.path.dirname(__file__)
formClass, baseClass = pg.Qt.loadUiType(os.path.join(path, 'uictest.ui'))
@ -20,4 +23,3 @@ def test_loadUiType():
ui.setupUi(w)
w.show()
app.processEvents()

View File

@ -6,7 +6,7 @@ the tear them down repeatedly.
The purpose of this is to attempt to generate segmentation faults.
"""
from PyQt4.QtTest import QTest
from pyqtgraph.Qt import QtTest
import pyqtgraph as pg
from random import seed, randint
import sys, gc, weakref
@ -63,7 +63,7 @@ def crashtest():
print("Caught interrupt; send another to exit.")
try:
for i in range(100):
QTest.qWait(100)
QtTest.QTest.qWait(100)
except KeyboardInterrupt:
thread.terminate()
break
@ -135,7 +135,7 @@ def showWidget():
def processEvents():
p('process events')
QTest.qWait(25)
QtTest.QTest.qWait(25)
class TstException(Exception):
pass
@ -157,4 +157,4 @@ def addReference():
if __name__ == '__main__':
test_stability()
test_stability()