diff options
author | Friedemann Kleint <[email protected]> | 2021-04-29 11:18:49 +0200 |
---|---|---|
committer | Friedemann Kleint <[email protected]> | 2021-04-29 15:56:58 +0200 |
commit | 6d2af409eedee377b3c2ba0cd8156b9409fabd9d (patch) | |
tree | 660f8fd87f77c1030cf97cc65345b9a941a321e4 /sources/pyside6/tests/QtGui | |
parent | 88fff87519e741a3a999b8c1545834d116859faa (diff) |
Tests: Fix some space-related flake8 warnings
Change-Id: I9b0ad08839bf1246620c557ec304dfa90882907b
Reviewed-by: Christian Tismer <[email protected]>
Diffstat (limited to 'sources/pyside6/tests/QtGui')
39 files changed, 122 insertions, 47 deletions
diff --git a/sources/pyside6/tests/QtGui/bug_1091.py b/sources/pyside6/tests/QtGui/bug_1091.py index 1e5ae4ce6..965f14811 100644 --- a/sources/pyside6/tests/QtGui/bug_1091.py +++ b/sources/pyside6/tests/QtGui/bug_1091.py @@ -45,5 +45,6 @@ class QPainterTestCase(unittest.TestCase): self.assertTrue("PixmapFragment" in dir(QPainter)) self.assertTrue("drawPixmapFragments" in dir(QPainter)) + if __name__ == "__main__": unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_300_test.py b/sources/pyside6/tests/QtGui/bug_300_test.py index 8d944840c..9a708f903 100644 --- a/sources/pyside6/tests/QtGui/bug_300_test.py +++ b/sources/pyside6/tests/QtGui/bug_300_test.py @@ -45,9 +45,10 @@ class TestQAbstractItemModelSignals(unittest.TestCase): def testSignals(self): self._called = False m = QStringListModel() - m.rowsAboutToBeInserted[QModelIndex,int,int].connect(self.sigCallback) + m.rowsAboutToBeInserted[QModelIndex, int, int].connect(self.sigCallback) m.insertRows(0, 3) self.assertTrue(self._called) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_367.py b/sources/pyside6/tests/QtGui/bug_367.py index 2dfc140f4..eba44105c 100644 --- a/sources/pyside6/tests/QtGui/bug_367.py +++ b/sources/pyside6/tests/QtGui/bug_367.py @@ -47,12 +47,13 @@ class BugTest(UsesQApplication): parentItem = model.invisibleRootItem() for i in range(10): item = QStandardItem() - rcount = sys.getrefcount(item) + rcount = sys.getrefcount(item) parentItem.appendRow(item) - self.assertEqual(rcount+1, sys.getrefcount(item)) + self.assertEqual(rcount + 1, sys.getrefcount(item)) parentItem = item self.assertTrue(True) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_480.py b/sources/pyside6/tests/QtGui/bug_480.py index 39707fb01..cd3fd1d6b 100644 --- a/sources/pyside6/tests/QtGui/bug_480.py +++ b/sources/pyside6/tests/QtGui/bug_480.py @@ -49,6 +49,7 @@ class BuggyWidget(QWidget): # this cause a segfault during the ownership transfer self.verticalLayout.addLayout(self.gridLayout) + class LayoutTransferOwnerShip(unittest.TestCase): def testBug(self): app = QApplication([]) @@ -57,6 +58,7 @@ class LayoutTransferOwnerShip(unittest.TestCase): w.show() self.assertTrue(True) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_606.py b/sources/pyside6/tests/QtGui/bug_606.py index 918960612..e82cdc593 100644 --- a/sources/pyside6/tests/QtGui/bug_606.py +++ b/sources/pyside6/tests/QtGui/bug_606.py @@ -39,6 +39,7 @@ import PySide6 from PySide6.QtGui import QVector2D, QVector3D, QVector4D from PySide6.QtGui import QColor + class testCases(unittest.TestCase): def testQVector2DToTuple(self): vec = QVector2D(1, 2) @@ -57,5 +58,6 @@ class testCases(unittest.TestCase): c.setRgb(1, 2, 3) self.assertEqual((1, 2, 3, 255), c.toTuple()) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_617.py b/sources/pyside6/tests/QtGui/bug_617.py index 008ab488f..d917745be 100644 --- a/sources/pyside6/tests/QtGui/bug_617.py +++ b/sources/pyside6/tests/QtGui/bug_617.py @@ -54,5 +54,6 @@ class Bug617(unittest.TestCase): e = MyEvent() self.assertEqual(repr(e.type()), 'PySide6.QtCore.QEvent.Type(999)') + if __name__ == "__main__": - unittest.main() + unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_652.py b/sources/pyside6/tests/QtGui/bug_652.py index 3758f2edc..5feecd64a 100644 --- a/sources/pyside6/tests/QtGui/bug_652.py +++ b/sources/pyside6/tests/QtGui/bug_652.py @@ -46,6 +46,7 @@ class MyData(QTextBlockUserData): def getMyNiceData(self): return self.data + class TestBug652(unittest.TestCase): """Segfault when using QTextBlock::setUserData due to missing ownership transfer""" def testIt(self): @@ -63,5 +64,6 @@ class TestBug652(unittest.TestCase): self.assertEqual(type(blk.userData()), MyData) self.assertEqual(blk.userData().getMyNiceData(), heyHo) + if __name__ == "__main__": unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_660.py b/sources/pyside6/tests/QtGui/bug_660.py index 61ae00a11..9c3cdcfe6 100644 --- a/sources/pyside6/tests/QtGui/bug_660.py +++ b/sources/pyside6/tests/QtGui/bug_660.py @@ -37,26 +37,29 @@ init_test_paths(False) from PySide6.QtGui import QStandardItemModel, QStandardItem + class MyItemModel(QStandardItemModel): - def __init__(self,parent=None): + def __init__(self, parent=None): super().__init__(parent) self.appendRow([QStandardItem('Item 1'),]) def mimeTypes(self): - mtypes = super(MyItemModel,self).mimeTypes() + mtypes = super(MyItemModel, self).mimeTypes() mtypes.append('application/my-form') return mtypes - def mimeData(self,indexes): - self.__mimedata = super(MyItemModel,self).mimeData(indexes) - self.__mimedata.setData('application/my-form',bytes('hi', "UTF-8")) + def mimeData(self, indexes): + self.__mimedata = super(MyItemModel, self).mimeData(indexes) + self.__mimedata.setData('application/my-form', bytes('hi', "UTF-8")) return self.__mimedata + class TestBug660(unittest.TestCase): '''QMimeData type deleted prematurely when overriding mime-type in QStandardItemModel drag and drop''' def testIt(self): model = MyItemModel() - model.mimeData([model.index(0, 0)]) # if it doesn't raise an exception it's all right! + model.mimeData([model.index(0, 0)]) # if it doesn't raise an exception it's all right! + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_740.py b/sources/pyside6/tests/QtGui/bug_740.py index 91aa23c86..41824fb70 100644 --- a/sources/pyside6/tests/QtGui/bug_740.py +++ b/sources/pyside6/tests/QtGui/bug_740.py @@ -39,10 +39,12 @@ from helper.usesqapplication import UsesQApplication from PySide6.QtCore import QSize from PySide6.QtGui import QBitmap, QImage + class TestQBitmap(UsesQApplication): def testFromDataMethod(self): dataBits = bytes('\x38\x28\x38\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\xfe\xfe\x7c\x7c\x38\x38\x10\x10', "UTF-8") - bim = QBitmap.fromData(QSize(8, 48), dataBits, QImage.Format_Mono) # missing function + bim = QBitmap.fromData(QSize(8, 48), dataBits, QImage.Format_Mono) # missing function + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_743.py b/sources/pyside6/tests/QtGui/bug_743.py index e74b32ba3..189eaf2c8 100644 --- a/sources/pyside6/tests/QtGui/bug_743.py +++ b/sources/pyside6/tests/QtGui/bug_743.py @@ -37,14 +37,16 @@ init_test_paths(False) from PySide6.QtGui import QMatrix4x4 + class TestQMatrix(unittest.TestCase): def testOperator(self): - m = QMatrix4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) + m = QMatrix4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) v = 1 for x in range(4): for y in range(4): - self.assertEqual(m[x,y], v) + self.assertEqual(m[x, y], v) v += 1 + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_991.py b/sources/pyside6/tests/QtGui/bug_991.py index 4738f4f04..3bdf0b02f 100644 --- a/sources/pyside6/tests/QtGui/bug_991.py +++ b/sources/pyside6/tests/QtGui/bug_991.py @@ -38,6 +38,7 @@ init_test_paths(False) from PySide6.QtCore import QObject from PySide6.QtGui import QPen, QBrush + class TestBug991 (unittest.TestCase): def testReprFunction(self): reprPen = repr(QPen()) @@ -47,5 +48,6 @@ class TestBug991 (unittest.TestCase): reprObject = repr(QObject()) self.assertTrue(reprObject.startswith("<PySide6.QtCore.QObject")) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_PYSIDE-344.py b/sources/pyside6/tests/QtGui/bug_PYSIDE-344.py index f221aebd4..3dfada26c 100644 --- a/sources/pyside6/tests/QtGui/bug_PYSIDE-344.py +++ b/sources/pyside6/tests/QtGui/bug_PYSIDE-344.py @@ -51,6 +51,7 @@ def testList(): QVector2D(1, 1), QVector3D(1, 1, 1), QVector4D(1, 1, 1, 1), QQuaternion(1, 1, 1, 1)] + class TestMulDiv(unittest.TestCase): def testMultiplication(self): @@ -69,5 +70,6 @@ class TestMulDiv(unittest.TestCase): fails += ' ' + type(a).__name__ self.assertEqual(fails, '') + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/deepcopy_test.py b/sources/pyside6/tests/QtGui/deepcopy_test.py index e1f0240b0..ca7692c39 100644 --- a/sources/pyside6/tests/QtGui/deepcopy_test.py +++ b/sources/pyside6/tests/QtGui/deepcopy_test.py @@ -44,12 +44,14 @@ from PySide6.QtGui import QVector2D, QVector3D, QVector4D from PySide6.QtGui import QColor, QTransform, QKeySequence, QQuaternion from PySide6.QtGui import QPolygon + class DeepCopyHelper: def testCopy(self): copy = deepcopy([self.original])[0] self.assertTrue(copy is not self.original) self.assertEqual(copy, self.original) + class DeepCopyColorHelperF: def testCopy(self): copy = deepcopy([self.original])[0] @@ -63,46 +65,57 @@ class QColorDeepCopy(DeepCopyHelper, unittest.TestCase): def setUp(self): self.original = QColor("red") + class QColorRGBDeepCopy(DeepCopyColorHelperF, unittest.TestCase): def setUp(self): self.original = QColor.fromRgbF(0.2, 0.3, 0.4, 0.5) + class QColorHSLDeepCopy(DeepCopyColorHelperF, unittest.TestCase): def setUp(self): self.original = QColor.fromHslF(0.2, 0.3, 0.4, 0.5) + class QColorHSVDeepCopy(DeepCopyColorHelperF, unittest.TestCase): def setUp(self): self.original = QColor.fromHsvF(0.2, 0.3, 0.4, 0.5) + class QColorCMYKDeepCopy(DeepCopyColorHelperF, unittest.TestCase): def setUp(self): self.original = QColor.fromCmykF(0.2, 0.3, 0.4, 0.5, 0.6) + class QTransformDeepCopy(DeepCopyHelper, unittest.TestCase): def setUp(self): self.original = QTransform(1, 2, 3, 4, 5, 6, 7, 8, 9) + class QKeySequenceDeepCopy(DeepCopyHelper, unittest.TestCase): def setUp(self): self.original = QKeySequence("Ctrl+P") + class QQuaternionDeepCopy(DeepCopyHelper, unittest.TestCase): def setUp(self): self.original = QQuaternion(1, 2, 3, 4) + class QVector2DDeepCopy(DeepCopyHelper, unittest.TestCase): def setUp(self): self.original = QVector2D(1, 2) + class QVector3DDeepCopy(DeepCopyHelper, unittest.TestCase): def setUp(self): self.original = QVector3D(1, 2, 3) + class QVector4DDeepCopy(DeepCopyHelper, unittest.TestCase): def setUp(self): self.original = QVector4D(1, 2, 3, 4) + class QPolygonDeepCopy(DeepCopyHelper, unittest.TestCase): def setUp(self): self.original = QPolygon([QPoint(1, 2), QPoint(3, 4), QPoint(5, 6)]) diff --git a/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py b/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py index 2537bc5b2..5383f79d7 100644 --- a/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py +++ b/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py @@ -41,23 +41,24 @@ from PySide6.QtGui import QImage, qRgb from helper.usesqapplication import UsesQApplication + class SetPixelFloat(UsesQApplication): '''Test case for calling setPixel with float as argument''' def setUp(self): - #Acquire resources + # Acquire resources super(SetPixelFloat, self).setUp() self.color = qRgb(255, 0, 0) self.image = QImage(200, 200, QImage.Format_RGB32) def tearDown(self): - #Release resources + # Release resources del self.color del self.image super(SetPixelFloat, self).tearDown() def testFloat(self): - #QImage.setPixel(float, float, color) - Implicit conversion + # QImage.setPixel(float, float, color) - Implicit conversion self.image.setPixel(3.14, 4.2, self.color) self.assertEqual(self.image.pixel(3.14, 4.2), self.color) diff --git a/sources/pyside6/tests/QtGui/pyside_reload_test.py b/sources/pyside6/tests/QtGui/pyside_reload_test.py index 87d311596..1c3070e57 100644 --- a/sources/pyside6/tests/QtGui/pyside_reload_test.py +++ b/sources/pyside6/tests/QtGui/pyside_reload_test.py @@ -46,6 +46,7 @@ dst = os.path.join(workdir, 'test_module.py') shutil.copyfile(src, dst) sys.path.append(workdir) + def reload_module(moduleName): importlib.reload(moduleName) @@ -60,6 +61,7 @@ def increment_module_value(): cacheFile = importlib.util.cache_from_source(dst) os.remove(cacheFile) + class TestModuleReloading(unittest.TestCase): def testModuleReloading(self): @@ -79,6 +81,7 @@ class TestModuleReloading(unittest.TestCase): reload_module(sys.modules['test_module']) self.assertEqual(test_module.Sentinel.value, 12) + if __name__ == "__main__": unittest.main() diff --git a/sources/pyside6/tests/QtGui/qcolor_reduce_test.py b/sources/pyside6/tests/QtGui/qcolor_reduce_test.py index ce855dba1..0df95781c 100644 --- a/sources/pyside6/tests/QtGui/qcolor_reduce_test.py +++ b/sources/pyside6/tests/QtGui/qcolor_reduce_test.py @@ -38,6 +38,7 @@ init_test_paths(False) from PySide6.QtGui import QColor + class TestQColor (unittest.TestCase): def reduceColor(self, c): p = pickle.dumps(c) @@ -63,5 +64,6 @@ class TestQColor (unittest.TestCase): def testReduceHsv(self): self.reduceColor(QColor.fromHsvF(0.1, 0.2, 0.3, 0.4)) + if __name__ == "__main__": unittest.main() diff --git a/sources/pyside6/tests/QtGui/qcolor_test.py b/sources/pyside6/tests/QtGui/qcolor_test.py index 6eaaa94a9..85ba2de2d 100644 --- a/sources/pyside6/tests/QtGui/qcolor_test.py +++ b/sources/pyside6/tests/QtGui/qcolor_test.py @@ -50,21 +50,21 @@ class QColorGetTest(unittest.TestCase): self.assertEqual(self.color.getRgb(), (20, 40, 60, 80)) def testGetHslF(self): - hls = colorsys.rgb_to_hls(20.0/255, 40.0/255, 60.0/255) + hls = colorsys.rgb_to_hls(20.0 / 255, 40.0 / 255, 60.0 / 255) hsla = hls[0], hls[2], hls[1], self.color.alphaF() - for x, y in zip(self.color.getHslF(), hsla): # Due to rounding problems - self.assertTrue(x - y < 1/100000.0) + for x, y in zip(self.color.getHslF(), hsla): # Due to rounding problems + self.assertTrue(x - y < 1 / 100000.0) def testGetHsv(self): - hsv = colorsys.rgb_to_hsv(20.0/255, 40.0/255, 60.0/255) - hsva = int(hsv[0]*360.0), int(hsv[1]*255), int(hsv[2]*256), self.color.alpha() + hsv = colorsys.rgb_to_hsv(20.0 / 255, 40.0 / 255, 60.0 / 255) + hsva = int(hsv[0] * 360.0), int(hsv[1] * 255), int(hsv[2] * 256), self.color.alpha() self.assertEqual(self.color.getHsv(), hsva) - def testGetCmyk(self): # not supported by colorsys + def testGetCmyk(self): # not supported by colorsys self.assertEqual(self.color.getCmyk(), (170, 85, 0, 195, 80)) - def testGetCmykF(self): # not supported by colorsys - for x, y in zip(self.color.getCmykF(), (170/255.0, 85/255.0, 0, 195/255.0, 80/255.0)): + def testGetCmykF(self): # not supported by colorsys + for x, y in zip(self.color.getCmykF(), (170 / 255.0, 85 / 255.0, 0, 195 / 255.0, 80 / 255.0)): self.assertTrue(x - y < 1/10000.0) @@ -76,7 +76,7 @@ class QColorQRgbConstructor(unittest.TestCase): def testBasic(self): '''QColor(QRgb)''' color = QColor(255, 0, 0) - #QRgb format #AARRGGBB + # QRgb format #AARRGGBB rgb = 0x00FF0000 self.assertEqual(QColor(rgb), color) @@ -126,5 +126,6 @@ class QColorRepr(unittest.TestCase): c2 = eval(c.__str__()) self.assertEqual(c, c2) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/qcursor_test.py b/sources/pyside6/tests/QtGui/qcursor_test.py index fcab714a9..181ad29cd 100644 --- a/sources/pyside6/tests/QtGui/qcursor_test.py +++ b/sources/pyside6/tests/QtGui/qcursor_test.py @@ -42,11 +42,13 @@ init_test_paths(False) from PySide6.QtGui import QBitmap, QCursor, QPixmap from helper.usesqapplication import UsesQApplication + class TestQCursor(UsesQApplication): def testQCursorConstructor(self): bmp = QBitmap(16, 16) cursor = QCursor(bmp, bmp, 16, 16) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/qdatastream_gui_operators_test.py b/sources/pyside6/tests/QtGui/qdatastream_gui_operators_test.py index ed1ff4528..83d206cce 100644 --- a/sources/pyside6/tests/QtGui/qdatastream_gui_operators_test.py +++ b/sources/pyside6/tests/QtGui/qdatastream_gui_operators_test.py @@ -42,6 +42,7 @@ from PySide6.QtGui import QPixmap, QColor from helper.usesqapplication import UsesQApplication + class QPixmapQDatastream(UsesQApplication): '''QDataStream <<>> QPixmap''' @@ -62,7 +63,7 @@ class QPixmapQDatastream(UsesQApplication): self.read_stream >> self.output_pixmap image = self.output_pixmap.toImage() - pixel = image.pixel(10,10) + pixel = image.pixel(10, 10) self.assertEqual(pixel, QColor(Qt.transparent).rgba()) self.assertEqual(self.source_pixmap.toImage(), image) diff --git a/sources/pyside6/tests/QtGui/qdesktopservices_test.py b/sources/pyside6/tests/QtGui/qdesktopservices_test.py index fb635e142..1981b52a6 100644 --- a/sources/pyside6/tests/QtGui/qdesktopservices_test.py +++ b/sources/pyside6/tests/QtGui/qdesktopservices_test.py @@ -40,11 +40,13 @@ init_test_paths(False) from PySide6.QtGui import QDesktopServices from PySide6.QtCore import QUrl + class QDesktopServicesTest(unittest.TestCase): def testOpenUrl(self): # At the bare minimum check that they return false for invalid url's url = QUrl() self.assertEqual(QDesktopServices.openUrl(url), False) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/qfontmetrics_test.py b/sources/pyside6/tests/QtGui/qfontmetrics_test.py index 44ae75a0d..9f3099acd 100644 --- a/sources/pyside6/tests/QtGui/qfontmetrics_test.py +++ b/sources/pyside6/tests/QtGui/qfontmetrics_test.py @@ -230,5 +230,6 @@ class QCharTest(QFontMetricsFTest): retCh = self.metrics.horizontalAdvance('a') self.assertTrue(retCh > 0) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/qguiapplication_test.py b/sources/pyside6/tests/QtGui/qguiapplication_test.py index 35b9574ea..ae661b695 100644 --- a/sources/pyside6/tests/QtGui/qguiapplication_test.py +++ b/sources/pyside6/tests/QtGui/qguiapplication_test.py @@ -37,6 +37,7 @@ init_test_paths(False) from PySide6.QtGui import QGuiApplication + class TestQGuiApplication(unittest.TestCase): def testNoArguments(self): app = QGuiApplication() diff --git a/sources/pyside6/tests/QtGui/qicon_test.py b/sources/pyside6/tests/QtGui/qicon_test.py index 24378b844..a7a1d6bf7 100644 --- a/sources/pyside6/tests/QtGui/qicon_test.py +++ b/sources/pyside6/tests/QtGui/qicon_test.py @@ -47,5 +47,6 @@ class QIconCtorWithNoneTest(TimedQApplication): pixmap = icon.pixmap(48, 48) self.app.exec_() + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/qitemselection_test.py b/sources/pyside6/tests/QtGui/qitemselection_test.py index 157c1bacb..1cfa92774 100644 --- a/sources/pyside6/tests/QtGui/qitemselection_test.py +++ b/sources/pyside6/tests/QtGui/qitemselection_test.py @@ -39,6 +39,7 @@ from helper.usesqapplication import UsesQApplication from PySide6.QtCore import QItemSelection from PySide6.QtGui import QStandardItemModel + class QItemSelectionTest(UsesQApplication): def testLen(self): model = QStandardItemModel(2, 2) @@ -46,9 +47,10 @@ class QItemSelectionTest(UsesQApplication): model.insertRow(1) model.insertColumn(0) model.insertColumn(1) - selection = QItemSelection(model.index(0,0), model.index(1,1)) + selection = QItemSelection(model.index(0, 0), model.index(1, 1)) self.assertEqual(len(selection), 1) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/qkeysequence_test.py b/sources/pyside6/tests/QtGui/qkeysequence_test.py index 896447740..3bcdf636b 100644 --- a/sources/pyside6/tests/QtGui/qkeysequence_test.py +++ b/sources/pyside6/tests/QtGui/qkeysequence_test.py @@ -40,6 +40,7 @@ from PySide6.QtGui import QKeySequence from helper.usesqapplication import UsesQApplication + class QKeySequenceTest(UsesQApplication): def testGetItemOperator(self): diff --git a/sources/pyside6/tests/QtGui/qpainter_test.py b/sources/pyside6/tests/QtGui/qpainter_test.py index 752475494..2a9db8598 100644 --- a/sources/pyside6/tests/QtGui/qpainter_test.py +++ b/sources/pyside6/tests/QtGui/qpainter_test.py @@ -86,12 +86,12 @@ class QPainterDrawText(UsesQGuiApplication): def testDrawOverloads(self): '''Calls QPainter.drawLines overloads, if something is wrong Exception and chaos ensues. Bug #395''' - self.painter.drawLines([QLine(QPoint(0,0), QPoint(1,1))]) - self.painter.drawLines([QPoint(0,0), QPoint(1,1)]) - self.painter.drawLines([QPointF(0,0), QPointF(1,1)]) - self.painter.drawLines([QLineF(QPointF(0,0), QPointF(1,1))]) - self.painter.drawPoints([QPoint(0,0), QPoint(1,1)]) - self.painter.drawPoints([QPointF(0,0), QPointF(1,1)]) + self.painter.drawLines([QLine(QPoint(0, 0), QPoint(1, 1))]) + self.painter.drawLines([QPoint(0, 0), QPoint(1, 1)]) + self.painter.drawLines([QPointF(0, 0), QPointF(1, 1)]) + self.painter.drawLines([QLineF(QPointF(0, 0), QPointF(1, 1))]) + self.painter.drawPoints([QPoint(0, 0), QPoint(1, 1)]) + self.painter.drawPoints([QPointF(0, 0), QPointF(1, 1)]) self.painter.drawConvexPolygon([QPointF(10.0, 80.0), QPointF(20.0, 10.0), QPointF(80.0, 30.0), @@ -122,7 +122,6 @@ class QPainterDrawText(UsesQGuiApplication): self.painter.drawPointsNp(x, y) - class SetBrushWithOtherArgs(UsesQGuiApplication): '''Using qpainter.setBrush with args other than QBrush''' diff --git a/sources/pyside6/tests/QtGui/qpdfwriter_test.py b/sources/pyside6/tests/QtGui/qpdfwriter_test.py index a58b9242e..61a16159f 100644 --- a/sources/pyside6/tests/QtGui/qpdfwriter_test.py +++ b/sources/pyside6/tests/QtGui/qpdfwriter_test.py @@ -39,6 +39,7 @@ from helper.usesqapplication import UsesQApplication from PySide6.QtGui import QPageLayout, QPageSize, QPdfWriter, QTextDocument from PySide6.QtCore import QDir, QMarginsF, QTemporaryFile + class QPdfWriterTest(UsesQApplication): def testWrite(self): @@ -51,5 +52,6 @@ class QPdfWriterTest(UsesQApplication): temporaryFile.close() self.assertTrue(temporaryFile.size() > 0) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/qpixelformat_test.py b/sources/pyside6/tests/QtGui/qpixelformat_test.py index 30241f50d..448bc3d5a 100644 --- a/sources/pyside6/tests/QtGui/qpixelformat_test.py +++ b/sources/pyside6/tests/QtGui/qpixelformat_test.py @@ -41,6 +41,7 @@ from helper.usesqapplication import UsesQApplication from PySide6.QtCore import QSize, Qt from PySide6.QtGui import QColor, QImage, QPixelFormat + class QPixelFormatTest(UsesQApplication): def test(self): image = QImage(QSize(200, 200), QImage.Format_ARGB32) @@ -53,5 +54,6 @@ class QPixelFormatTest(UsesQApplication): self.assertEqual(pixelFormat.blueSize(), 8) self.assertEqual(pixelFormat.bitsPerPixel(), 32) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/qpixmap_test.py b/sources/pyside6/tests/QtGui/qpixmap_test.py index 9da7044f9..70de1ebf6 100644 --- a/sources/pyside6/tests/QtGui/qpixmap_test.py +++ b/sources/pyside6/tests/QtGui/qpixmap_test.py @@ -48,7 +48,7 @@ class QPixmapTest(UsesQApplication): self.assertEqual(type(obj.property('foo')), QPixmap) def testQSizeConstructor(self): - pixmap = QPixmap(QSize(10,20)) + pixmap = QPixmap(QSize(10, 20)) self.assertTrue(pixmap.size().height(), 20) def testQStringConstructor(self): @@ -63,7 +63,7 @@ class QPixmapTest(UsesQApplication): self.assertTrue(pixmap.loadFromData(data)) def testQPixmapLoadFromDataWithPython(self): - data = open(os.path.join(os.path.dirname(__file__),'sample.png'),'rb').read() + data = open(os.path.join(os.path.dirname(__file__), 'sample.png'), 'rb').read() pixmap = QPixmap() self.assertTrue(pixmap.loadFromData(data)) @@ -73,7 +73,7 @@ class QPixmapToImage(UsesQApplication): def testFilledImage(self): '''QPixmap.fill + toImage + image.pixel''' pixmap = QPixmap(100, 200) - pixmap.fill(Qt.red) # Default Qt.white + pixmap.fill(Qt.red) # Default Qt.white self.assertEqual(pixmap.height(), 200) self.assertEqual(pixmap.width(), 100) @@ -83,7 +83,7 @@ class QPixmapToImage(UsesQApplication): self.assertEqual(image.height(), 200) self.assertEqual(image.width(), 100) - pixel = image.pixel(10,10) + pixel = image.pixel(10, 10) self.assertEqual(pixel, QColor(Qt.red).rgba()) diff --git a/sources/pyside6/tests/QtGui/qpixmapcache_test.py b/sources/pyside6/tests/QtGui/qpixmapcache_test.py index 3b45b1b91..6a7ef330a 100644 --- a/sources/pyside6/tests/QtGui/qpixmapcache_test.py +++ b/sources/pyside6/tests/QtGui/qpixmapcache_test.py @@ -75,6 +75,7 @@ class QPixmapCacheTest(UsesQApplication): self.assertEqual(QPixmapCache.find(key).toImage().bits(), pm3.toImage().bits()) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/qradialgradient_test.py b/sources/pyside6/tests/QtGui/qradialgradient_test.py index 61a9fc3ef..e36fc6fd9 100644 --- a/sources/pyside6/tests/QtGui/qradialgradient_test.py +++ b/sources/pyside6/tests/QtGui/qradialgradient_test.py @@ -38,6 +38,7 @@ init_test_paths(False) from PySide6.QtGui import QRadialGradient from PySide6.QtCore import QPointF + class QRadialGradientConstructor(unittest.TestCase): def _compare(self, qptf, tpl): self.assertEqual((qptf.x(), qptf.y()), tpl) @@ -60,5 +61,6 @@ class QRadialGradientConstructor(unittest.TestCase): grad.setCenter(QPointF(1, 2)) self._compare(grad.center(), (1.0, 2.0)) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/qregion_test.py b/sources/pyside6/tests/QtGui/qregion_test.py index bd843e162..e5b6a1d56 100644 --- a/sources/pyside6/tests/QtGui/qregion_test.py +++ b/sources/pyside6/tests/QtGui/qregion_test.py @@ -39,6 +39,7 @@ from PySide6.QtGui import QRegion from PySide6.QtCore import QPoint from helper.usesqapplication import UsesQApplication + class QRegionTest(UsesQApplication): def testFunctionUnit(self): @@ -46,10 +47,11 @@ class QRegionTest(UsesQApplication): r2 = QRegion(5, 5, 10, 10) ru = r.united(r2) - self.assertTrue(ru.contains(QPoint(0,0))) - self.assertTrue(ru.contains(QPoint(5,5))) - self.assertTrue(ru.contains(QPoint(10,10))) - self.assertTrue(ru.contains(QPoint(14,14))) + self.assertTrue(ru.contains(QPoint(0, 0))) + self.assertTrue(ru.contains(QPoint(5, 5))) + self.assertTrue(ru.contains(QPoint(10, 10))) + self.assertTrue(ru.contains(QPoint(14, 14))) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/qstylehints_test.py b/sources/pyside6/tests/QtGui/qstylehints_test.py index b7b2e9471..c113469ee 100644 --- a/sources/pyside6/tests/QtGui/qstylehints_test.py +++ b/sources/pyside6/tests/QtGui/qstylehints_test.py @@ -40,10 +40,12 @@ init_test_paths(False) from helper.usesqapplication import UsesQApplication from PySide6.QtGui import QStyleHints + class QStyleHintsTest(UsesQApplication): def test(self): styleHints = self.app.styleHints() self.assertTrue(styleHints.startDragDistance() > 0) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/qtextdocument_undoredo_test.py b/sources/pyside6/tests/QtGui/qtextdocument_undoredo_test.py index caeb0e7cc..8ef520eea 100644 --- a/sources/pyside6/tests/QtGui/qtextdocument_undoredo_test.py +++ b/sources/pyside6/tests/QtGui/qtextdocument_undoredo_test.py @@ -37,6 +37,7 @@ init_test_paths(False) from PySide6.QtGui import QTextDocument, QTextCursor + class QTextDocumentTest(unittest.TestCase): def testUndoRedo(self): @@ -60,6 +61,7 @@ class QTextDocumentTest(unittest.TestCase): self.assertTrue(doc.isUndoAvailable()) self.assertEqual(doc.toPlainText(), text) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/qtextdocumentwriter_test.py b/sources/pyside6/tests/QtGui/qtextdocumentwriter_test.py index cf3721684..6838931d4 100644 --- a/sources/pyside6/tests/QtGui/qtextdocumentwriter_test.py +++ b/sources/pyside6/tests/QtGui/qtextdocumentwriter_test.py @@ -46,10 +46,11 @@ class QTextDocumentWriterTest(unittest.TestCase): doc = QTextDocument(text) b = QBuffer() b.open(QBuffer.ReadWrite) - writer = QTextDocumentWriter(b, bytes("plaintext", "UTF-8")); - writer.write(doc); + writer = QTextDocumentWriter(b, bytes("plaintext", "UTF-8")) + writer.write(doc) b.close() self.assertEqual(b.buffer(), text) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/qtextline_test.py b/sources/pyside6/tests/QtGui/qtextline_test.py index 58bd48620..511292d9b 100644 --- a/sources/pyside6/tests/QtGui/qtextline_test.py +++ b/sources/pyside6/tests/QtGui/qtextline_test.py @@ -38,6 +38,7 @@ init_test_paths(False) from PySide6.QtGui import QTextLayout from helper.usesqapplication import UsesQApplication + class QTextLineTest(UsesQApplication): def testCursorToX(self): @@ -52,6 +53,7 @@ class QTextLineTest(UsesQApplication): self.assertEqual(type(x), float) self.assertEqual(type(cursorPos), int) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside6/tests/QtGui/qtransform_test.py b/sources/pyside6/tests/QtGui/qtransform_test.py index 8fcddf3ec..777e88225 100644 --- a/sources/pyside6/tests/QtGui/qtransform_test.py +++ b/sources/pyside6/tests/QtGui/qtransform_test.py @@ -38,6 +38,7 @@ init_test_paths(False) from PySide6.QtCore import QPointF from PySide6.QtGui import QTransform, QPolygonF, QPolygonF + class QTransformTest(unittest.TestCase): def testMap(self): @@ -86,7 +87,6 @@ class QTransformTest(unittest.TestCase): self.assertEqual(t1, r2) - def testsquareToQuad(self): q1 = QPolygonF() q1.append(QPointF(10.0, 10.0)) @@ -105,5 +105,5 @@ class QTransformTest(unittest.TestCase): if __name__ == "__main__": - unittest.main() + unittest.main() diff --git a/sources/pyside6/tests/QtGui/repr_test.py b/sources/pyside6/tests/QtGui/repr_test.py index 3b732ce77..29c5a9627 100644 --- a/sources/pyside6/tests/QtGui/repr_test.py +++ b/sources/pyside6/tests/QtGui/repr_test.py @@ -44,28 +44,34 @@ from PySide6.QtGui import QVector2D, QVector3D, QVector4D from PySide6.QtGui import QColor, QTransform, QKeySequence, QQuaternion from PySide6.QtGui import QPolygon + class ReprCopyHelper: def testCopy(self): copy = eval(self.original.__repr__()) self.assertTrue(copy is not self.original) self.assertEqual(copy, self.original) + class QTransformReprCopy(ReprCopyHelper, unittest.TestCase): def setUp(self): self.original = QTransform(1, 2, 3, 4, 5, 6, 7, 8, 9) + class QQuaternionReprCopy(ReprCopyHelper, unittest.TestCase): def setUp(self): self.original = QQuaternion(1, 2, 3, 4) + class QVector2DReprCopy(ReprCopyHelper, unittest.TestCase): def setUp(self): self.original = QVector2D(1, 2) + class QVector3DReprCopy(ReprCopyHelper, unittest.TestCase): def setUp(self): self.original = QVector3D(1, 2, 3) + class QVector4DReprCopy(ReprCopyHelper, unittest.TestCase): def setUp(self): self.original = QVector4D(1, 2, 3, 4) diff --git a/sources/pyside6/tests/QtGui/timed_app_and_patching_test.py b/sources/pyside6/tests/QtGui/timed_app_and_patching_test.py index 1290fed90..4dcdea57b 100644 --- a/sources/pyside6/tests/QtGui/timed_app_and_patching_test.py +++ b/sources/pyside6/tests/QtGui/timed_app_and_patching_test.py @@ -45,13 +45,14 @@ class TestTimedApp(TimedQApplication): '''Simple test case for TimedQApplication''' def testFoo(self): - #Simple test of TimedQApplication + # Simple test of TimedQApplication self.app.exec_() def fix_for_QtGui(QtGui): QtGui.something = 42 + class TestPatchingFramework(unittest.TestCase): """Simple test that verifies that deprecated.py works""" @@ -63,5 +64,6 @@ class TestPatchingFramework(unittest.TestCase): importhandler.finish_import(QtGui) self.assertTrue(hasattr(QtGui, something)) + if __name__ == '__main__': unittest.main() |