aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2024-03-12 09:52:51 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2024-03-13 12:12:36 +0100
commitfaae00a81778adb97814db2a9a4c3cb233e6ecc0 (patch)
tree32f7dc75e9560e3598b6dd3d583658daeb14ca0f /sources/shiboken6
parent8c0add0ae09e86a7a1f243a4c46d4fcee16d10d5 (diff)
shiboken tests/minimalbinding: Fix flake8 warnings
- Remove * imports - Streamline some conditions and code Pick-to: 6.6 6.5 Change-Id: Ifd8d836adc2f306fb8b442b715e0495bae3ccb08 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken6')
-rw-r--r--sources/shiboken6/tests/minimalbinding/brace_pattern_test.py8
-rw-r--r--sources/shiboken6/tests/minimalbinding/listuser_test.py14
-rw-r--r--sources/shiboken6/tests/minimalbinding/minbool_test.py22
-rw-r--r--sources/shiboken6/tests/minimalbinding/obj_test.py2
-rw-r--r--sources/shiboken6/tests/minimalbinding/typedef_test.py52
-rw-r--r--sources/shiboken6/tests/minimalbinding/val_test.py1
6 files changed, 59 insertions, 40 deletions
diff --git a/sources/shiboken6/tests/minimalbinding/brace_pattern_test.py b/sources/shiboken6/tests/minimalbinding/brace_pattern_test.py
index f625fc776..946a869db 100644
--- a/sources/shiboken6/tests/minimalbinding/brace_pattern_test.py
+++ b/sources/shiboken6/tests/minimalbinding/brace_pattern_test.py
@@ -11,7 +11,7 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from shiboken_paths import init_paths
init_paths()
-from shiboken6 import Shiboken
+from shiboken6 import Shiboken # noqa: F401
from shibokensupport.signature.lib.tool import build_brace_pattern
@@ -21,8 +21,9 @@ against a slower reference implementation.
The pattern is crucial, because it is used heavily in signature.parser .
"""
-# A slow reference parser for braces and strings
+
def check(s):
+ """A slow reference parser for braces and strings"""
open, close = "[{(<", "]})>"
escape, quote = "\\", '"'
instring = blind = False
@@ -41,8 +42,7 @@ def check(s):
stack.append(c)
elif c in close:
pos = close.index(c)
- if ((len(stack) > 0) and
- (open[pos] == stack[len(stack)-1])):
+ if len(stack) > 0 and open[pos] == stack[len(stack) - 1]:
stack.pop()
else:
return False
diff --git a/sources/shiboken6/tests/minimalbinding/listuser_test.py b/sources/shiboken6/tests/minimalbinding/listuser_test.py
index 4d092b33c..b30bb653a 100644
--- a/sources/shiboken6/tests/minimalbinding/listuser_test.py
+++ b/sources/shiboken6/tests/minimalbinding/listuser_test.py
@@ -32,7 +32,7 @@ class ExtListUser(ListUser):
return [not mb1, not mb2]
def oredMinBoolList(self, minBoolList):
- return not reduce(lambda a, b: a|b, minBoolList)
+ return not reduce(lambda a, b: a | b, minBoolList)
def createValList(self, num):
return [Val(i) for i in range(0, num * 2, 2)]
@@ -303,14 +303,16 @@ class ListOfIntListConversionTest(unittest.TestCase):
def testSumListOfIntListsFromExtendedClass(self):
lu = ExtListUser()
lst = [range(4)] * 4
- self.assertEqual(lu.sumListOfIntLists(lst), sum([sum(line) for line in [range(4)] * 4]) * 2)
- self.assertEqual(lu.callSumListOfIntLists(lst), sum([sum(line) for line in [range(4)] * 4]) * 2)
+ self.assertEqual(lu.sumListOfIntLists(lst),
+ sum([sum(line) for line in [range(4)] * 4]) * 2)
+ self.assertEqual(lu.callSumListOfIntLists(lst),
+ sum([sum(line) for line in [range(4)] * 4]) * 2)
def testOpaqueContainer(self):
lu = ListUser()
# Set via Python
- python_list = [1,2]
+ python_list = [1, 2]
lu.setStdIntList(python_list)
self.assertEqual(len(lu.m_stdIntList), 2)
self.assertEqual(lu.m_stdIntList[0], 1)
@@ -331,8 +333,8 @@ class ListOfIntListConversionTest(unittest.TestCase):
self.assertEqual(lu.m_stdIntList[2], 5)
# Access list via getter
- l = lu.getIntList()
- l.append(6)
+ il = lu.getIntList()
+ il.append(6)
self.assertEqual(len(lu.m_stdIntList), 4)
self.assertEqual(lu.m_stdIntList[3], 6)
diff --git a/sources/shiboken6/tests/minimalbinding/minbool_test.py b/sources/shiboken6/tests/minimalbinding/minbool_test.py
index 331b410b3..d9ce0eac0 100644
--- a/sources/shiboken6/tests/minimalbinding/minbool_test.py
+++ b/sources/shiboken6/tests/minimalbinding/minbool_test.py
@@ -13,32 +13,34 @@ init_paths()
from minimal import MinBoolUser
+
class DerivedMinBoolUser (MinBoolUser):
def returnMyselfVirtual(self):
return MinBoolUser()
+
class MinBoolTest(unittest.TestCase):
def testMinBoolUser(self):
mbuTrue = MinBoolUser()
mbuFalse = MinBoolUser()
mbuTrue.setMinBool(True)
- self.assertEqual(mbuFalse.minBool(), False)
- self.assertEqual(mbuTrue.minBool(), True)
- self.assertEqual(mbuTrue.callInvertedMinBool(), False)
+ self.assertFalse(mbuFalse.minBool())
+ self.assertTrue(mbuTrue.minBool())
+ self.assertFalse(mbuTrue.callInvertedMinBool())
- self.assertEqual(mbuTrue.minBool() == True, True)
- self.assertEqual(False == mbuFalse.minBool(), True)
- self.assertEqual(mbuTrue.minBool() == mbuFalse.minBool(), False)
+ self.assertTrue(mbuTrue.minBool())
+ self.assertFalse(mbuFalse.minBool())
+ self.assertTrue(mbuTrue.minBool() != mbuFalse.minBool())
- self.assertEqual(mbuFalse.minBool() != True, True)
- self.assertEqual(True != mbuFalse.minBool(), True)
- self.assertEqual(mbuTrue.minBool() != mbuFalse.minBool(), True)
+ self.assertFalse(mbuFalse.minBool())
+ self.assertFalse(mbuFalse.minBool())
+ self.assertTrue(mbuTrue.minBool() != mbuFalse.minBool())
def testVirtuals(self):
dmbu = DerivedMinBoolUser()
self.assertEqual(dmbu.invertedMinBool(), True)
+
if __name__ == '__main__':
unittest.main()
-
diff --git a/sources/shiboken6/tests/minimalbinding/obj_test.py b/sources/shiboken6/tests/minimalbinding/obj_test.py
index 0d8a2dced..e873845de 100644
--- a/sources/shiboken6/tests/minimalbinding/obj_test.py
+++ b/sources/shiboken6/tests/minimalbinding/obj_test.py
@@ -12,6 +12,7 @@ from shiboken_paths import init_paths
init_paths()
from minimal import Obj
+
class ExtObj(Obj):
def __init__(self, objId):
Obj.__init__(self, objId)
@@ -91,4 +92,3 @@ class ObjTest(unittest.TestCase):
if __name__ == '__main__':
unittest.main()
-
diff --git a/sources/shiboken6/tests/minimalbinding/typedef_test.py b/sources/shiboken6/tests/minimalbinding/typedef_test.py
index 1d878be30..c2fc8fc12 100644
--- a/sources/shiboken6/tests/minimalbinding/typedef_test.py
+++ b/sources/shiboken6/tests/minimalbinding/typedef_test.py
@@ -2,7 +2,6 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-from functools import reduce
import os
import sys
import unittest
@@ -11,7 +10,9 @@ from pathlib import Path
sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from shiboken_paths import init_paths
init_paths()
-from minimal import *
+from minimal import (arrayFunc, arrayFuncInt, arrayFuncIntReturn,
+ arrayFuncIntReturnTypedef, arrayFuncIntTypedef,
+ arrayFuncReturn, arrayFuncReturnTypedef, arrayFuncTypedef)
try:
import numpy as np
@@ -31,29 +32,37 @@ class TypedefTest(unittest.TestCase):
self.assertTrue(arrayFuncInt(none), "None is empty, arrayFuncInt should return true")
self.assertFalse(arrayFuncInt(full), "Full is NOT empty, arrayFuncInt should return false")
- self.assertTrue(arrayFuncInt(np.array(none)), "None is empty, arrayFuncInt should return true")
- self.assertFalse(arrayFuncInt(np.array(full)), "Full is NOT empty, arrayFuncInt should return false")
+ self.assertTrue(arrayFuncInt(np.array(none)),
+ "None is empty, arrayFuncInt should return true")
+ self.assertFalse(arrayFuncInt(np.array(full)),
+ "Full is NOT empty, arrayFuncInt should return false")
def test_arrayFuncIntTypedef(self):
none = ()
full = (1, 2, 3)
- self.assertTrue(arrayFuncIntTypedef(none), "None is empty, arrayFuncIntTypedef should return true")
- self.assertFalse(arrayFuncIntTypedef(full), "Full is NOT empty, arrayFuncIntTypedef should return false")
+ self.assertTrue(arrayFuncIntTypedef(none),
+ "None is empty, arrayFuncIntTypedef should return true")
+ self.assertFalse(arrayFuncIntTypedef(full),
+ "Full is NOT empty, arrayFuncIntTypedef should return false")
- self.assertTrue(arrayFuncIntTypedef(np.array(none)), "None is empty, arrayFuncIntTypedef should return true")
- self.assertFalse(arrayFuncIntTypedef(np.array(full)), "Full is NOT empty, arrayFuncIntTypedef should return false")
+ self.assertTrue(arrayFuncIntTypedef(np.array(none)),
+ "None is empty, arrayFuncIntTypedef should return true")
+ self.assertFalse(arrayFuncIntTypedef(np.array(full)),
+ "Full is NOT empty, arrayFuncIntTypedef should return false")
def test_arrayFuncIntReturn(self):
none = arrayFuncIntReturn(0)
full = arrayFuncIntReturn(self.the_size)
self.assertTrue((len(none) == 0), "none should be empty")
- self.assertTrue((len(full) == self.the_size), "full should have " + str(self.the_size) + " elements")
+ self.assertTrue((len(full) == self.the_size),
+ f"full should have {self.the_size} elements")
def test_arrayFuncIntReturnTypedef(self):
none = arrayFuncIntReturnTypedef(0)
full = arrayFuncIntReturnTypedef(self.the_size)
self.assertTrue((len(none) == 0), "none should be empty")
- self.assertTrue((len(full) == self.the_size), "full should have " + str(self.the_size) + " elements")
+ self.assertTrue((len(full) == self.the_size),
+ f"full should have {self.the_size} elements")
def test_arrayFunc(self):
none = ()
@@ -62,30 +71,37 @@ class TypedefTest(unittest.TestCase):
self.assertFalse(arrayFunc(full), "Full is NOT empty, arrayFunc should return false")
self.assertTrue(arrayFunc(np.array(none)), "None is empty, arrayFunc should return true")
- self.assertFalse(arrayFunc(np.array(full)), "Full is NOT empty, arrayFunc should return false")
+ self.assertFalse(arrayFunc(np.array(full)),
+ "Full is NOT empty, arrayFunc should return false")
def test_arrayFuncTypedef(self):
none = ()
full = (1, 2, 3)
- self.assertTrue(arrayFuncTypedef(none), "None is empty, arrayFuncTypedef should return true")
- self.assertFalse(arrayFuncTypedef(full), "Full is NOT empty, arrayFuncTypedef should return false")
+ self.assertTrue(arrayFuncTypedef(none),
+ "None is empty, arrayFuncTypedef should return true")
+ self.assertFalse(arrayFuncTypedef(full),
+ "Full is NOT empty, arrayFuncTypedef should return false")
- self.assertTrue(arrayFuncTypedef(np.array(none)), "None is empty, arrayFuncTypedef should return true")
- self.assertFalse(arrayFuncTypedef(np.array(full)), "Full is NOT empty, arrayFuncTypedef should return false")
+ self.assertTrue(arrayFuncTypedef(np.array(none)),
+ "None is empty, arrayFuncTypedef should return true")
+ self.assertFalse(arrayFuncTypedef(np.array(full)),
+ "Full is NOT empty, arrayFuncTypedef should return false")
def test_arrayFuncReturn(self):
none = arrayFuncReturn(0)
full = arrayFuncReturn(self.the_size)
self.assertTrue((len(none) == 0), "none should be empty")
- self.assertTrue((len(full) == self.the_size), "full should have " + str(self.the_size) + " elements")
+ self.assertTrue((len(full) == self.the_size),
+ f"full should have {self.the_size} elements")
def test_arrayFuncReturnTypedef(self):
none = arrayFuncReturnTypedef(0)
full = arrayFuncReturnTypedef(self.the_size)
self.assertTrue((len(none) == 0), "none should be empty")
- self.assertTrue((len(full) == self.the_size), "full should have " + str(self.the_size) + " elements")
+ self.assertTrue((len(full) == self.the_size),
+ f"full should have {self.the_size} elements")
if __name__ == '__main__':
- if np != None:
+ if np is not None:
unittest.main()
diff --git a/sources/shiboken6/tests/minimalbinding/val_test.py b/sources/shiboken6/tests/minimalbinding/val_test.py
index 6403b5f14..b8225a247 100644
--- a/sources/shiboken6/tests/minimalbinding/val_test.py
+++ b/sources/shiboken6/tests/minimalbinding/val_test.py
@@ -92,4 +92,3 @@ class ValTest(unittest.TestCase):
if __name__ == '__main__':
unittest.main()
-