aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2024-03-12 10:04:44 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2024-03-12 12:00:34 +0100
commit1bba44ea86209b122da8c23b6a7e12ab0063f1aa (patch)
tree47b5c6d4e67f67e0b39b1ae3f6b4e1550d97a1da /sources/shiboken6/tests
parentb9a77537b8d7194b6cce020e059098e6efa4d930 (diff)
shiboken tests/otherbinding: Fix flake8 warnings
- Remove * imports Pick-to: 6.6 6.5 Change-Id: Ife84bc03d89eb95c3ddc58394ddaae1c82a601a7 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/shiboken6/tests')
-rw-r--r--sources/shiboken6/tests/otherbinding/collector_external_operator_test.py3
-rw-r--r--sources/shiboken6/tests/otherbinding/conversion_operator_for_class_without_implicit_conversions_test.py28
-rw-r--r--sources/shiboken6/tests/otherbinding/extended_multiply_operator_test.py3
-rw-r--r--sources/shiboken6/tests/otherbinding/module_reload_test.py2
-rw-r--r--sources/shiboken6/tests/otherbinding/new_ctor_operator_test.py11
-rw-r--r--sources/shiboken6/tests/otherbinding/objtypehashes_test.py5
-rw-r--r--sources/shiboken6/tests/otherbinding/otherderived_test.py15
-rw-r--r--sources/shiboken6/tests/otherbinding/othertypesystypedef_test.py3
-rw-r--r--sources/shiboken6/tests/otherbinding/signature_test.py4
-rw-r--r--sources/shiboken6/tests/otherbinding/smartptr_test.py2
-rw-r--r--sources/shiboken6/tests/otherbinding/test_module_template.py13
-rw-r--r--sources/shiboken6/tests/otherbinding/typediscovery_test.py14
-rw-r--r--sources/shiboken6/tests/otherbinding/usersprimitivefromothermodule_test.py2
-rw-r--r--sources/shiboken6/tests/otherbinding/wrongctor_test.py10
14 files changed, 73 insertions, 42 deletions
diff --git a/sources/shiboken6/tests/otherbinding/collector_external_operator_test.py b/sources/shiboken6/tests/otherbinding/collector_external_operator_test.py
index ab9a67345..2ba21653d 100644
--- a/sources/shiboken6/tests/otherbinding/collector_external_operator_test.py
+++ b/sources/shiboken6/tests/otherbinding/collector_external_operator_test.py
@@ -16,6 +16,7 @@ init_paths()
from sample import Collector, ObjectType
from other import OtherObjectType
+
class CollectorOtherObjectType(unittest.TestCase):
'''Test cases for Collector << OtherObjectType'''
@@ -33,6 +34,6 @@ class CollectorOtherObjectType(unittest.TestCase):
collector << obj
self.assertEqual(collector.items()[0], obj.identifier() * 2)
+
if __name__ == '__main__':
unittest.main()
-
diff --git a/sources/shiboken6/tests/otherbinding/conversion_operator_for_class_without_implicit_conversions_test.py b/sources/shiboken6/tests/otherbinding/conversion_operator_for_class_without_implicit_conversions_test.py
index 220cd3c98..bd00b5892 100644
--- a/sources/shiboken6/tests/otherbinding/conversion_operator_for_class_without_implicit_conversions_test.py
+++ b/sources/shiboken6/tests/otherbinding/conversion_operator_for_class_without_implicit_conversions_test.py
@@ -18,8 +18,10 @@ init_paths()
from sample import NoImplicitConversion
from other import ExtendsNoImplicitConversion
+
class ConversionOperatorForClassWithoutImplicitConversionsTest(unittest.TestCase):
- '''Tests calling NoImplicitConversion constructor using a ExtendsNoImplicitConversion parameter.'''
+ '''Tests calling NoImplicitConversion constructor using a
+ ExtendsNoImplicitConversion parameter.'''
def testNoImplicitConversion(self):
'''Basic test to see if the NoImplicitConversion is Ok.'''
@@ -27,27 +29,33 @@ class ConversionOperatorForClassWithoutImplicitConversionsTest(unittest.TestCase
# NoImplicitConversion.receivesNoImplicitConversionByValue(NoImplicitConversion)
self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByValue(obj))
# NoImplicitConversion.receivesNoImplicitConversionByPointer(NoImplicitConversion*)
- self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByPointer(obj))
+ self.assertEqual(obj.objId(),
+ NoImplicitConversion.receivesNoImplicitConversionByPointer(obj))
# NoImplicitConversion.receivesNoImplicitConversionByReference(NoImplicitConversion&)
- self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByReference(obj))
+ self.assertEqual(obj.objId(),
+ NoImplicitConversion.receivesNoImplicitConversionByReference(obj))
def testPassingExtendsNoImplicitConversionAsNoImplicitConversionByValue(self):
- '''Gives an ExtendsNoImplicitConversion object to a function expecting a NoImplicitConversion, passing by value.'''
+ '''Gives an ExtendsNoImplicitConversion object to a function expecting a
+ NoImplicitConversion, passing by value.'''
obj = ExtendsNoImplicitConversion(123)
self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByValue(obj))
def testPassingExtendsNoImplicitConversionAsNoImplicitConversionByReference(self):
- '''Gives an ExtendsNoImplicitConversion object to a function expecting a NoImplicitConversion, passing by reference.'''
+ '''Gives an ExtendsNoImplicitConversion object to a function expecting a
+ NoImplicitConversion, passing by reference.'''
obj = ExtendsNoImplicitConversion(123)
- self.assertEqual(obj.objId(), NoImplicitConversion.receivesNoImplicitConversionByReference(obj))
+ self.assertEqual(obj.objId(),
+ NoImplicitConversion.receivesNoImplicitConversionByReference(obj))
def testPassingExtendsNoImplicitConversionAsNoImplicitConversionByPointer(self):
- '''Gives an ExtendsNoImplicitConversion object to a function expecting a NoImplicitConversion, passing by pointer.
- This should not be accepted, since pointers should not be converted.'''
+ '''Gives an ExtendsNoImplicitConversion object to a function expecting
+ a NoImplicitConversion, passing by pointer. This should not be
+ accepted, since pointers should not be converted.'''
obj = ExtendsNoImplicitConversion(123)
- self.assertRaises(TypeError, NoImplicitConversion.receivesNoImplicitConversionByPointer, obj)
+ self.assertRaises(TypeError,
+ NoImplicitConversion.receivesNoImplicitConversionByPointer, obj)
if __name__ == '__main__':
unittest.main()
-
diff --git a/sources/shiboken6/tests/otherbinding/extended_multiply_operator_test.py b/sources/shiboken6/tests/otherbinding/extended_multiply_operator_test.py
index 169f5259d..abbef6231 100644
--- a/sources/shiboken6/tests/otherbinding/extended_multiply_operator_test.py
+++ b/sources/shiboken6/tests/otherbinding/extended_multiply_operator_test.py
@@ -16,6 +16,7 @@ init_paths()
from sample import Point
from other import Number
+
class PointOperationsWithNumber(unittest.TestCase):
'''Test cases for libsample's Point multiply operator defined in libother module.'''
@@ -39,6 +40,6 @@ class PointOperationsWithNumber(unittest.TestCase):
num = Number(11)
self.assertEqual(pt * num.value(), pt * 11)
+
if __name__ == '__main__':
unittest.main()
-
diff --git a/sources/shiboken6/tests/otherbinding/module_reload_test.py b/sources/shiboken6/tests/otherbinding/module_reload_test.py
index 5be2b4191..bde2f5236 100644
--- a/sources/shiboken6/tests/otherbinding/module_reload_test.py
+++ b/sources/shiboken6/tests/otherbinding/module_reload_test.py
@@ -21,6 +21,7 @@ dst = workdir / 'test_module.py'
shutil.copyfile(src, dst)
sys.path.append(os.fspath(workdir))
+
class TestModuleReloading(unittest.TestCase):
def testModuleReloading(self):
@@ -32,5 +33,6 @@ class TestModuleReloading(unittest.TestCase):
reload(test_module)
self.assertFalse(oldObject is test_module.obj)
+
if __name__ == "__main__":
unittest.main()
diff --git a/sources/shiboken6/tests/otherbinding/new_ctor_operator_test.py b/sources/shiboken6/tests/otherbinding/new_ctor_operator_test.py
index 5e3536c93..d6c356436 100644
--- a/sources/shiboken6/tests/otherbinding/new_ctor_operator_test.py
+++ b/sources/shiboken6/tests/otherbinding/new_ctor_operator_test.py
@@ -2,7 +2,8 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-'''Tests calling Str constructor using a Number parameter, being that number defines a cast operator to Str.'''
+'''Tests calling Str constructor using a Number parameter, being that number defines
+ a cast operator to Str.'''
import os
import sys
@@ -16,8 +17,10 @@ init_paths()
from sample import Str
from other import Number
+
class NewCtorOperatorTest(unittest.TestCase):
- '''Tests calling Str constructor using a Number parameter, being that number defines a cast operator to Str.'''
+ '''Tests calling Str constructor using a Number parameter, being that number
+ defines a cast operator to Str.'''
def testNumber(self):
'''Basic test to see if the Number class is Ok.'''
@@ -29,8 +32,8 @@ class NewCtorOperatorTest(unittest.TestCase):
'''Try to build a Str from 'sample' module with a Number argument from 'other' module.'''
value = 123
num = Number(value)
- string = Str(num)
+ string = Str(num) # noqa: F841
+
if __name__ == '__main__':
unittest.main()
-
diff --git a/sources/shiboken6/tests/otherbinding/objtypehashes_test.py b/sources/shiboken6/tests/otherbinding/objtypehashes_test.py
index d2c441058..d2cd7de5b 100644
--- a/sources/shiboken6/tests/otherbinding/objtypehashes_test.py
+++ b/sources/shiboken6/tests/otherbinding/objtypehashes_test.py
@@ -9,10 +9,10 @@ from pathlib import Path
sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from shiboken_paths import init_paths
init_paths()
-from sample import *
-from other import *
+from sample import HandleHolder
from shiboken6 import Shiboken
+
class TestHashFuncs (unittest.TestCase):
def testIt(self):
@@ -30,6 +30,5 @@ class TestHashFuncs (unittest.TestCase):
self.assertEqual(hash1_2, hash1)
-
if __name__ == '__main__':
unittest.main()
diff --git a/sources/shiboken6/tests/otherbinding/otherderived_test.py b/sources/shiboken6/tests/otherbinding/otherderived_test.py
index 1b876e1ed..459f474f1 100644
--- a/sources/shiboken6/tests/otherbinding/otherderived_test.py
+++ b/sources/shiboken6/tests/otherbinding/otherderived_test.py
@@ -17,6 +17,7 @@ init_paths()
from sample import Abstract, Derived
from other import OtherDerived, Number
+
class Multiple(Derived, Number):
def __init__(self):
Derived.__init__(self, 42)
@@ -25,6 +26,7 @@ class Multiple(Derived, Number):
def testCall(self):
return True
+
class OtherDeviant(OtherDerived):
def __init__(self):
OtherDerived.__init__(self)
@@ -40,6 +42,7 @@ class OtherDeviant(OtherDerived):
def className(self):
return 'OtherDeviant'
+
class MultipleTest(unittest.TestCase):
'''Test case for Multiple derived class'''
@@ -58,6 +61,7 @@ class MultipleTest(unittest.TestCase):
self.assertTrue(o.value(), 42)
self.assertTrue(o.testCall())
+
class OtherDerivedTest(unittest.TestCase):
'''Test case for OtherDerived class'''
@@ -68,13 +72,15 @@ class OtherDerivedTest(unittest.TestCase):
self.assertTrue(inherited_methods.issubset(dir(OtherDerived)))
def testReimplementedPureVirtualMethodCall(self):
- '''Test if a Python override of a implemented pure virtual method is correctly called from C++.'''
+ '''Test if a Python override of a implemented pure virtual method is
+ correctly called from C++.'''
d = OtherDeviant()
d.callPureVirtual()
self.assertTrue(d.pure_virtual_called)
def testReimplementedVirtualMethodCall(self):
- '''Test if a Python override of a reimplemented virtual method is correctly called from C++.'''
+ '''Test if a Python override of a reimplemented virtual method is
+ correctly called from C++.'''
d = OtherDeviant()
d.callUnpureVirtual()
self.assertTrue(d.unpure_virtual_called)
@@ -86,7 +92,8 @@ class OtherDerivedTest(unittest.TestCase):
self.assertEqual(d.getClassName(), 'OtherDerived')
def testReimplementedVirtualMethodCallReturningString(self):
- '''Test if a Python override of a reimplemented virtual method is correctly called from C++.'''
+ '''Test if a Python override of a reimplemented virtual method is
+ correctly called from C++.'''
d = OtherDeviant()
self.assertEqual(d.className(), 'OtherDeviant')
self.assertEqual(d.getClassName(), 'OtherDeviant')
@@ -97,6 +104,6 @@ class OtherDerivedTest(unittest.TestCase):
d = OtherDerived(objId)
self.assertEqual(Abstract.getObjectId(d), objId)
+
if __name__ == '__main__':
unittest.main()
-
diff --git a/sources/shiboken6/tests/otherbinding/othertypesystypedef_test.py b/sources/shiboken6/tests/otherbinding/othertypesystypedef_test.py
index 9ac2456c0..198c71693 100644
--- a/sources/shiboken6/tests/otherbinding/othertypesystypedef_test.py
+++ b/sources/shiboken6/tests/otherbinding/othertypesystypedef_test.py
@@ -13,8 +13,7 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from shiboken_paths import init_paths
init_paths()
-from other import (OtherValueWithUnitUser, ValueWithUnitIntInch,
- ValueWithUnitIntMillimeter)
+from other import (OtherValueWithUnitUser, ValueWithUnitIntMillimeter)
from sample import (ValueWithUnitDoubleMillimeter)
diff --git a/sources/shiboken6/tests/otherbinding/signature_test.py b/sources/shiboken6/tests/otherbinding/signature_test.py
index 93f080e6d..8db3e566b 100644
--- a/sources/shiboken6/tests/otherbinding/signature_test.py
+++ b/sources/shiboken6/tests/otherbinding/signature_test.py
@@ -16,8 +16,6 @@ init_paths()
from other import OtherObjectType
from shiboken_test_helper import objectFullname
-from shiboken6 import Shiboken
-
from shibokensupport.signature import get_signature
@@ -29,7 +27,7 @@ class SignatureTest(unittest.TestCase):
def testNamespaceFromOtherModule(self):
argType = get_signature(OtherObjectType.enumAsInt).parameters["value"].annotation
self.assertEqual(objectFullname(argType),
- "sample.SampleNamespace.SomeClass.PublicScopedEnum")
+ "sample.SampleNamespace.SomeClass.PublicScopedEnum")
if __name__ == '__main__':
diff --git a/sources/shiboken6/tests/otherbinding/smartptr_test.py b/sources/shiboken6/tests/otherbinding/smartptr_test.py
index 6479e6337..fd5c7fa09 100644
--- a/sources/shiboken6/tests/otherbinding/smartptr_test.py
+++ b/sources/shiboken6/tests/otherbinding/smartptr_test.py
@@ -13,8 +13,6 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from shiboken_paths import init_paths
init_paths()
-from smart import Integer
-from sample import Str
from other import SmartPtrTester
diff --git a/sources/shiboken6/tests/otherbinding/test_module_template.py b/sources/shiboken6/tests/otherbinding/test_module_template.py
index 183ba9fe5..36ab43ae3 100644
--- a/sources/shiboken6/tests/otherbinding/test_module_template.py
+++ b/sources/shiboken6/tests/otherbinding/test_module_template.py
@@ -1,13 +1,22 @@
# 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 other import *
-from sample import *
+import os
+import sys
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from shiboken_paths import init_paths
+init_paths()
+
+from other import OtherObjectType
+from sample import ObjectType
class MyObjectType(ObjectType):
pass
+
class MyOtherObjectType(OtherObjectType):
value = 10
diff --git a/sources/shiboken6/tests/otherbinding/typediscovery_test.py b/sources/shiboken6/tests/otherbinding/typediscovery_test.py
index 51fc7c01b..791d3bdce 100644
--- a/sources/shiboken6/tests/otherbinding/typediscovery_test.py
+++ b/sources/shiboken6/tests/otherbinding/typediscovery_test.py
@@ -13,9 +13,10 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from shiboken_paths import init_paths
init_paths()
-from sample import Abstract, Base1, Derived, MDerived1, MDerived3, SonOfMDerived1
+from sample import Abstract, Base1, Derived
from other import OtherMultipleDerived
+
class TypeDiscoveryTest(unittest.TestCase):
def testPureVirtualsOfImpossibleTypeDiscovery(self):
@@ -29,18 +30,19 @@ class TypeDiscoveryTest(unittest.TestCase):
self.assertEqual(type(a), Derived)
def testMultipleInheritance(self):
- obj = OtherMultipleDerived.createObject("Base1");
+ obj = OtherMultipleDerived.createObject("Base1")
self.assertEqual(type(obj), Base1)
# PYSIDE-868: In case of multiple inheritance, a factory
# function will return the base class wrapper.
- obj = OtherMultipleDerived.createObject("MDerived1");
+ obj = OtherMultipleDerived.createObject("MDerived1")
self.assertEqual(type(obj), Base1)
- obj = OtherMultipleDerived.createObject("SonOfMDerived1");
+ obj = OtherMultipleDerived.createObject("SonOfMDerived1")
self.assertEqual(type(obj), Base1)
- obj = OtherMultipleDerived.createObject("MDerived3");
+ obj = OtherMultipleDerived.createObject("MDerived3")
self.assertEqual(type(obj), Base1)
- obj = OtherMultipleDerived.createObject("OtherMultipleDerived");
+ obj = OtherMultipleDerived.createObject("OtherMultipleDerived")
self.assertEqual(type(obj), Base1)
+
if __name__ == '__main__':
unittest.main()
diff --git a/sources/shiboken6/tests/otherbinding/usersprimitivefromothermodule_test.py b/sources/shiboken6/tests/otherbinding/usersprimitivefromothermodule_test.py
index b464fa566..15a988326 100644
--- a/sources/shiboken6/tests/otherbinding/usersprimitivefromothermodule_test.py
+++ b/sources/shiboken6/tests/otherbinding/usersprimitivefromothermodule_test.py
@@ -14,6 +14,7 @@ from shiboken_paths import init_paths
init_paths()
from other import Number
+
class UserDefinedPrimitiveTypeFromRequiredModuleTest(unittest.TestCase):
def testUsersPrimitiveFromRequiredModuleAsArgument(self):
@@ -28,5 +29,6 @@ class UserDefinedPrimitiveTypeFromRequiredModuleTest(unittest.TestCase):
cpx = number.toComplex()
self.assertEqual(number.value(), int(cpx.real))
+
if __name__ == '__main__':
unittest.main()
diff --git a/sources/shiboken6/tests/otherbinding/wrongctor_test.py b/sources/shiboken6/tests/otherbinding/wrongctor_test.py
index 9aacfa9ac..b9251b428 100644
--- a/sources/shiboken6/tests/otherbinding/wrongctor_test.py
+++ b/sources/shiboken6/tests/otherbinding/wrongctor_test.py
@@ -10,17 +10,19 @@ from pathlib import Path
sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from shiboken_paths import init_paths
init_paths()
-from sample import *
-from other import *
+from sample import Abstract, ObjectType
+from other import OtherDerived
+
class Foo(OtherDerived):
def __init__(self):
- Abstract.__init__(self, 2) # this should raise an exception
+ Abstract.__init__(self, 2) # this should raise an exception
+
class Foo2(ObjectType, OtherDerived):
def __init__(self):
ObjectType.__init__(self)
- Abstract.__init__(self, 2) # this should raise an exception
+ Abstract.__init__(self, 2) # this should raise an exception
class WrongCtorTest(unittest.TestCase):