aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2024-11-01 13:07:39 +0100
committerChristian Tismer <tismer@stackless.com>2024-11-04 12:30:07 +0100
commitbe4e09c4fbda0844f16f2f064e5352f8eb1b60f0 (patch)
treedba7be9406c0e8de79606fe88f13a49c6218a6be /sources/pyside6/tests
parent07ee31548a3af6552e62625860c20772503e658c (diff)
type hints: Make the mypy cache more permanent, amended
It turned out that mypy is not loaded by COIN tests when requirements_coin.txt is used. Also enforce mypy existence in COIN to prevent further configuration errors. As a drive-by, a new cache is used that is > 10% faster. Task-number: PYSIDE-2846 Change-Id: I75a27cfd0cb0fb0d7cd44c2a121291af052b0d8f Pick-to: 6.8 6.8.0 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside6/tests')
-rw-r--r--sources/pyside6/tests/pysidetest/mypy_correctness_test.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/sources/pyside6/tests/pysidetest/mypy_correctness_test.py b/sources/pyside6/tests/pysidetest/mypy_correctness_test.py
index bad35a2f3..5f94f82ab 100644
--- a/sources/pyside6/tests/pysidetest/mypy_correctness_test.py
+++ b/sources/pyside6/tests/pysidetest/mypy_correctness_test.py
@@ -22,8 +22,13 @@ except ModuleNotFoundError:
import PySide6
from PySide6 import SKIP_MYPY_TEST
+qtest_env = os.environ.get("QTEST_ENVIRONMENT", "")
+is_ci = qtest_env == "ci"
+# When we are in COIN, we enforce mypy existence, to prevent misconfigurations.
+USE_MYPY = True if is_ci else HAVE_MYPY
-@unittest.skipIf(not HAVE_MYPY, "The mypy test was skipped because mypy is not installed")
+
+@unittest.skipIf(not USE_MYPY, "The mypy test was skipped because mypy is not installed")
@unittest.skipIf(SKIP_MYPY_TEST, "The mypy test was disabled")
class MypyCorrectnessTest(unittest.TestCase):
@@ -32,6 +37,8 @@ class MypyCorrectnessTest(unittest.TestCase):
self.build_dir = self.pyside_dir.parent.parent
os.chdir(self.build_dir)
self.project_dir = Path(__file__).resolve().parents[4]
+ # For safety about future changes, check that we are sitting above the sources dir.
+ self.assertTrue((self.project_dir / "sources").exists())
# Check if the project dir can be written. If so, put the mypy cache there.
test_fname = self.project_dir / ".tmp test writable"
try:
@@ -44,6 +51,7 @@ class MypyCorrectnessTest(unittest.TestCase):
self.cache_dir = ".mypy_cache" # This is the mypy default.
def testMypy(self):
+ self.assertTrue(HAVE_MYPY)
cmd = [sys.executable, "-m", "mypy", "--cache-dir", self.cache_dir, self.pyside_dir]
time_pre = time.time()
ret = subprocess.run(cmd, capture_output=True)