aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/tests')
-rw-r--r--sources/pyside6/tests/pysidetest/CMakeLists.txt1
-rw-r--r--sources/pyside6/tests/pysidetest/snake_case_imported.py25
-rw-r--r--sources/pyside6/tests/pysidetest/snake_case_imported_no_snake_case.py (renamed from sources/pyside6/tests/pysidetest/snake_case_sub.py)2
-rw-r--r--sources/pyside6/tests/pysidetest/snake_case_test.py18
4 files changed, 39 insertions, 7 deletions
diff --git a/sources/pyside6/tests/pysidetest/CMakeLists.txt b/sources/pyside6/tests/pysidetest/CMakeLists.txt
index 4a7e2e1d1..8b4de5d8e 100644
--- a/sources/pyside6/tests/pysidetest/CMakeLists.txt
+++ b/sources/pyside6/tests/pysidetest/CMakeLists.txt
@@ -156,7 +156,6 @@ PYSIDE_TEST(new_inherited_functions_test.py)
PYSIDE_TEST(notify_id.py)
PYSIDE_TEST(properties_test.py)
PYSIDE_TEST(property_python_test.py)
-PYSIDE_TEST(snake_case_sub.py)
PYSIDE_TEST(snake_case_test.py)
PYSIDE_TEST(true_property_test.py)
PYSIDE_TEST(qapp_like_a_macro_test.py)
diff --git a/sources/pyside6/tests/pysidetest/snake_case_imported.py b/sources/pyside6/tests/pysidetest/snake_case_imported.py
new file mode 100644
index 000000000..c79966e1e
--- /dev/null
+++ b/sources/pyside6/tests/pysidetest/snake_case_imported.py
@@ -0,0 +1,25 @@
+# Copyright (C) 2025 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+from __future__ import annotations
+
+import os
+import sys
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths # noqa: E402
+init_test_paths(False)
+
+from __feature__ import snake_case # noqa
+
+"""
+PYSIDE-3250: Tests that snake_case works when used in several files
+"""
+
+from PySide6.QtWidgets import QWidget # noqa: E402
+
+
+def test():
+ print(__name__)
+ widget = QWidget()
+ return widget.size_hint()
diff --git a/sources/pyside6/tests/pysidetest/snake_case_sub.py b/sources/pyside6/tests/pysidetest/snake_case_imported_no_snake_case.py
index e423542a6..a5ce14694 100644
--- a/sources/pyside6/tests/pysidetest/snake_case_sub.py
+++ b/sources/pyside6/tests/pysidetest/snake_case_imported_no_snake_case.py
@@ -20,4 +20,4 @@ from PySide6.QtWidgets import QWidget # noqa: E402
def test_no_snake_case():
print(__name__)
widget = QWidget()
- check = widget.sizeHint # noqa
+ return widget.sizeHint()
diff --git a/sources/pyside6/tests/pysidetest/snake_case_test.py b/sources/pyside6/tests/pysidetest/snake_case_test.py
index bdcd996c4..4667e584a 100644
--- a/sources/pyside6/tests/pysidetest/snake_case_test.py
+++ b/sources/pyside6/tests/pysidetest/snake_case_test.py
@@ -21,18 +21,26 @@ if not is_pypy:
from __feature__ import snake_case # noqa
from helper.usesqapplication import UsesQApplication
-import snake_case_sub
+import snake_case_imported
+import snake_case_imported_no_snake_case
@unittest.skipIf(is_pypy, "__feature__ cannot yet be used with PyPy")
class SnakeCaseNoPropagateTest(UsesQApplication):
- def testSnakeCase(self):
- # this worked
+ def testSnakeCaseImport(self):
+ """PYSIDE-3250: Test that snake case works when using it in imported modules."""
widget = QWidget()
- check = widget.size_hint # noqa
+ r1 = widget.size_hint()
+ r2 = snake_case_imported.test()
+ self.assertEqual(r1, r2)
- snake_case_sub.test_no_snake_case()
+ def testSnakeCaseImportNoSnakeCase(self):
+ """PYSIDE-2029: Tests that snake_case is isolated from imported modules."""
+ widget = QWidget()
+ r1 = widget.size_hint()
+ r2 = snake_case_imported_no_snake_case.test_no_snake_case()
+ self.assertEqual(r1, r2)
if __name__ == '__main__':