aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-08-17 12:40:24 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-08-18 18:40:07 +0200
commit3f7bb2243ab294e6daf48ac567faef5468b3477d (patch)
tree35658bb3fb05dd522c6c5b7af76abf893de2cf22
parent93980c4c653aaaa2ad98a9a6a49d3719738f7ed6 (diff)
Port some tests away from deprecated API
Use QRandomGenerator instead of deprecated qsrand() and remove usage of deprecated QPolygonF constructor taking the size. Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Change-Id: Ic4b773772555716636f5dfec797052a945d431cd Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--sources/pyside2/tests/QtCore/qsrand_test.py4
-rw-r--r--sources/pyside2/tests/QtGui/qpolygonf_test.py18
2 files changed, 13 insertions, 9 deletions
diff --git a/sources/pyside2/tests/QtCore/qsrand_test.py b/sources/pyside2/tests/QtCore/qsrand_test.py
index cdad78237..03814c950 100644
--- a/sources/pyside2/tests/QtCore/qsrand_test.py
+++ b/sources/pyside2/tests/QtCore/qsrand_test.py
@@ -35,14 +35,14 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide2.QtCore import qsrand
+from PySide2.QtCore import QRandomGenerator
class OverflowExceptionCollect(unittest.TestCase):
'''Test case for OverflowError exception during garbage collection. See bug #147'''
def testOverflow(self):
# NOTE: PyQt4 raises TypeError, but boost.python raises OverflowError
- self.assertRaises(OverflowError, qsrand, 42415335332353253)
+ self.assertRaises(OverflowError, QRandomGenerator, 42415335332353253)
# should not abort if bug #147 is fixed
gc.collect()
diff --git a/sources/pyside2/tests/QtGui/qpolygonf_test.py b/sources/pyside2/tests/QtGui/qpolygonf_test.py
index a21518a7e..d39b44827 100644
--- a/sources/pyside2/tests/QtGui/qpolygonf_test.py
+++ b/sources/pyside2/tests/QtGui/qpolygonf_test.py
@@ -34,23 +34,26 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide2.QtCore import *
-from PySide2.QtGui import *
+from PySide2.QtCore import QPoint, QPointF
+from PySide2.QtGui import QPolygon, QPolygonF
+
class QPolygonFNotIterableTest(unittest.TestCase):
"""Test if a QPolygonF is iterable"""
- def testIt(self):
- p = QPolygonF(4)
- self.assertEqual(len(p), 4)
+ def testIt(self):
+ points = []
for i in range(0, 4):
- p[i] = QPointF(float(i), float(i))
+ points.append(QPointF(float(i), float(i)))
+
+ p = QPolygonF(points)
+ self.assertEqual(len(p), 4)
i = 0
for point in p:
self.assertEqual(int(point.x()), i)
self.assertEqual(int(point.y()), i)
- i += 1;
+ i += 1
def testPolygonShiftOperators(self):
p = QPolygon()
@@ -58,5 +61,6 @@ class QPolygonFNotIterableTest(unittest.TestCase):
p << QPoint(10, 20) << QPoint(20, 30) << [QPoint(20, 30), QPoint(40, 50)]
self.assertEqual(len(p), 4)
+
if __name__ == '__main__':
unittest.main()