aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests/QtCore/attr_cache_py3k.py
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/tests/QtCore/attr_cache_py3k.py')
-rw-r--r--sources/pyside6/tests/QtCore/attr_cache_py3k.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/sources/pyside6/tests/QtCore/attr_cache_py3k.py b/sources/pyside6/tests/QtCore/attr_cache_py3k.py
new file mode 100644
index 000000000..c82dbbea3
--- /dev/null
+++ b/sources/pyside6/tests/QtCore/attr_cache_py3k.py
@@ -0,0 +1,36 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+'''
+Unit tests for attribute cache in Python 3
+
+This is the original code from the bug report
+https://bugreports.qt.io/browse/PYSIDE-60
+'''
+
+import os
+import sys
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1] / "util"))
+from init_paths import init_test_paths
+init_test_paths()
+
+from PySide6.QtCore import QObject
+
+
+class A(QObject):
+ instance = 1
+
+ @classmethod
+ def test(cls):
+ cls.instance
+ cls.instance = cls()
+ assert "<__main__.A(0x" in repr(cls.__dict__['instance'])
+ assert "<__main__.A(0x" in repr(cls.instance)
+ assert "<__main__.A(0x" in repr(type.__getattribute__(cls, 'instance'))
+
+
+if __name__ == "__main__":
+ A.test()