Fix some test suite setup mistakes
Marco Ricci

Marco Ricci commited on 2025-07-23 20:13:06
Zeige 3 geänderte Dateien mit 19 Einfügungen und 7 Löschungen.


These mistakes were carried over from v0.5, and cause woe on The
Annoying OS even before actually running any tests.
... ...
@@ -54,15 +54,26 @@ dev = [
54 54
     "mypy >= 1.0",
55 55
     "ruff >= 0.9.0",
56 56
     # Test dependencies should be installed as well, to have static
57
-    # analysis in the test suite working too.  `packaging` is needed
58
-    # because the test suite compares version numbers.
57
+    # analysis in the test suite working too.
58
+    #
59
+    # `packaging` is needed because the test suite compares version
60
+    # numbers.
61
+    #
62
+    # `pytest-xdist` is used by `hatch test -p`, but for the `psutil`
63
+    # extra, the `psutil` package provides no wheels for PyPy.  Users on
64
+    # The Annoying OS are especially screwed if they lack the admin
65
+    # priviledges necessary to install the developers' tools.  So skip
66
+    # the extra, and accept that for PyPy environments, `hatch test -p`
67
+    # will not be able to distinguish logical and physical CPU core
68
+    # counts.
59 69
     "coverage[toml] >= 7.4",
60 70
     "coverage-enable-subprocess >= 1.0",
61 71
     "hypothesis >= 6.0",
62 72
     "packaging",
63 73
     "pytest >= 8.1",
64 74
     "pytest-randomly >= 3.15",
65
-    "pytest-xdist[psutil] >= 3.6.0",
75
+    "pytest-xdist >= 3.6.0",
76
+    'pytest-xdist[psutil] >= 3.6.0; platform_python_implementation != "PyPy"',
66 77
     # Versions 6.130.13 through 6.135.1 of `hypothesis` use syntax only
67 78
     # available on Python 3.10 and later: `with (x as y, a as b)`
68 79
     'hypothesis != 6.130.13, != 6.131.*, != 6.132.*, != 6.133.*, != 6.134.*, != 6.135.0, != 6.135.1 ; python_version < "3.10"',
... ...
@@ -307,7 +318,8 @@ dependencies = [
307 318
     "packaging",
308 319
     "pytest >= 8.1",
309 320
     "pytest-randomly >= 3.15",
310
-    "pytest-xdist[psutil] >= 3.6.0",
321
+    "pytest-xdist >= 3.6.0",
322
+    'pytest-xdist[psutil] >= 3.6.0; platform_python_implementation != "PyPy"',
311 323
     'hypothesis != 6.130.13, != 6.131.*, != 6.132.*, != 6.133.*, != 6.134.*, != 6.135.0, != 6.135.1 ; python_version < "3.10"',
312 324
 ]
313 325
 matrix-name-format = '{variable}_{value}'
... ...
@@ -64,10 +64,10 @@ def get_vault_key() -> bytes:
64 64
 
65 65
     """
66 66
 
67
-    def getenv_environ(env_var: str) -> bytes:  # pragma: no cover
67
+    def getenv_environb(env_var: str) -> bytes:  # pragma: no cover
68 68
         return os.environb.get(env_var.encode('UTF-8'), b'')  # type: ignore[attr-defined]
69 69
 
70
-    def getenv_environb(env_var: str) -> bytes:  # pragma: no cover
70
+    def getenv_environ(env_var: str) -> bytes:  # pragma: no cover
71 71
         return os.environ.get(env_var, '').encode('UTF-8')
72 72
 
73 73
     getenv: Callable[[str], bytes] = (
... ...
@@ -1651,7 +1651,7 @@ def get_concurrency_limit() -> int:
1651 1651
     if sys.version_info >= (3, 13):
1652 1652
         result = os.process_cpu_count()
1653 1653
     else:
1654
-        with contextlib.suppress(ValueError):
1654
+        with contextlib.suppress(KeyError, ValueError):
1655 1655
             result = result or int(os.environ['PYTHON_CPU_COUNT'], 10)
1656 1656
         with contextlib.suppress(AttributeError):
1657 1657
             result = result or len(os.sched_getaffinity(os.getpid()))
1658 1658