aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/shibokenmodule/module_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/tests/shibokenmodule/module_test.py')
-rw-r--r--sources/shiboken6/tests/shibokenmodule/module_test.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/sources/shiboken6/tests/shibokenmodule/module_test.py b/sources/shiboken6/tests/shibokenmodule/module_test.py
index 9b9a5ad90..9f9f8f5a4 100644
--- a/sources/shiboken6/tests/shibokenmodule/module_test.py
+++ b/sources/shiboken6/tests/shibokenmodule/module_test.py
@@ -7,17 +7,19 @@ import unittest
from pathlib import Path
sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
-from shiboken_paths import init_paths
+from shiboken_paths import init_paths # noqa: E402
init_paths()
-from shiboken6 import Shiboken
-from sample import *
+from shiboken6 import Shiboken # noqa: E402
+from sample import BlackBox, ObjectType, ObjectModel, ObjectView, Point # noqa: E402
+
class MultipleInherited (ObjectType, Point):
def __init__(self):
ObjectType.__init__(self)
Point.__init__(self)
+
class TestShiboken(unittest.TestCase):
def testIsValid(self):
self.assertTrue(Shiboken.isValid(object()))
@@ -43,6 +45,16 @@ class TestShiboken(unittest.TestCase):
self.assertTrue(Shiboken.createdByPython(bb))
bb.disposeObjectType(bb.keepObjectType(obj))
+ def testWrapInstancePreserveId(self):
+ """PYSIDE-31: Verify that wrapInstance() returns the existing wrapper
+ even if a base class type is specified."""
+ v = ObjectView() # inherits ObjectType
+ addresses = Shiboken.getCppPointer(v)
+ self.assertTrue(addresses)
+ address = addresses[0]
+ wrapped = Shiboken.wrapInstance(address, ObjectType)
+ self.assertEqual(id(wrapped), id(v))
+
def testIsOwnedByPython(self):
obj = ObjectType()
self.assertTrue(Shiboken.ownedByPython(obj))
@@ -55,7 +67,7 @@ class TestShiboken(unittest.TestCase):
p = ObjectType()
obj = ObjectType(p)
obj2 = ObjectType(obj)
- obj3 = ObjectType(obj)
+ obj3 = ObjectType(obj) # noqa: F841
self.assertEqual(Shiboken.dump(None), "Ordinary Python type.")
Shiboken.dump(obj)
@@ -69,9 +81,9 @@ class TestShiboken(unittest.TestCase):
# Don't crash even after deleting an object
Shiboken.invalidate(obj)
- Shiboken.dump(obj) # deleted
- Shiboken.dump(p) # child deleted
- Shiboken.dump(obj2) # parent deleted
+ Shiboken.dump(obj) # deleted
+ Shiboken.dump(p) # child deleted
+ Shiboken.dump(obj2) # parent deleted
def testDelete(self):
obj = ObjectType()