Skip to content

Commit d039c54

Browse files
committed
Make tests tolerate environments without shell
1 parent 172f4ba commit d039c54

4 files changed

Lines changed: 18 additions & 11 deletions

File tree

.github/workflows/tests.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ jobs:
109109
EXTRA_PLATFORMS_TEST_MATRIX: ${{ toJson(matrix) }}
110110
run: >
111111
uv --no-progress run --frozen -- pytest
112+
--dist=loadgroup
113+
--numprocesses=auto
112114
--cov
113115
--cov-report=term
114116
--cov-report=xml

changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
> [!WARNING]
66
> This version is **not released yet** and is under active development.
77
8-
- Move `--cov` and `--cov-report=term` from `pyproject.toml` `[tool.pytest].addopts` into the CI workflow. Removes `pytest-cov` as an unconditional test-time dependency for downstream packagers.
8+
- Move `--cov`, `--cov-report=term`, `--numprocesses=auto`, and `--dist=loadgroup` from `pyproject.toml` `[tool.pytest].addopts` into the CI workflow. Removes `pytest-cov` and `pytest-xdist` as unconditional test-time dependencies for downstream packagers.
99
- Mark `test_pyproject_classifiers` with the new `network` marker. Sandboxed builds can exclude it with `pytest -m "not network"`.
10+
- Make `test_current_funcs` and `test_current_strict_mode` tolerate environments without a recognizable shell (Guix builders, BusyBox-only images). Shell joins `CI`, `terminal`, and `agent` in the optional-trait list.
1011

1112
## [`12.0.1` (2026-04-26)](https://github.com/kdeldycke/extra-platforms/compare/v12.0.0...v12.0.1)
1213

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,7 @@ markers = [
381381
"network: Tests that require network access (excluded with -m 'not network').",
382382
]
383383
addopts = [
384-
"--dist=loadgroup",
385384
"--durations=10",
386-
"--numprocesses=auto",
387385
]
388386
# Make sure tests that are expected to fail do not resurrect and start working all of a sudden.
389387
xfail_strict = true

tests/test_root.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
is_linux,
7979
is_macos,
8080
is_ubuntu,
81+
is_unknown_shell,
8182
is_windows,
8283
platform_data as platform_data_module,
8384
shell_data as shell_data_module,
@@ -270,8 +271,12 @@ def test_current_funcs():
270271
current_traits_results = current_traits()
271272
assert ALL_TRAITS.issuperset(current_traits_results)
272273

273-
# 1 architecture + 1 platform + 1 shell = 3 traits always detected.
274-
detected_traits = 3
274+
# 1 architecture + 1 platform = 2 traits always detected.
275+
detected_traits = 2
276+
# Shell is optional: minimal sandboxes (Guix builders, BusyBox-only images)
277+
# may have no recognizable shell.
278+
if not is_unknown_shell():
279+
detected_traits += 1
275280
# Terminal is optional: headless/CI environments may not have one.
276281
if is_any_terminal():
277282
detected_traits += 1
@@ -307,9 +312,9 @@ def test_current_funcs():
307312
assert current_platform_result is not UNKNOWN_PLATFORM
308313

309314
current_shell_result = current_shell()
310-
assert current_shell_result in ALL_SHELLS
311-
assert current_shell_result in current_traits_results
312-
assert current_shell_result is not UNKNOWN_SHELL
315+
assert current_shell_result in ALL_SHELLS | {UNKNOWN_SHELL}
316+
if current_shell_result is not UNKNOWN_SHELL:
317+
assert current_shell_result in current_traits_results
313318

314319
current_terminal_result = current_terminal()
315320
assert current_terminal_result in ALL_TERMINALS | {UNKNOWN_TERMINAL}
@@ -384,9 +389,10 @@ def test_current_strict_mode(
384389
):
385390
"""Test that ``current_*(strict=True)`` raises an error when unrecognized."""
386391
# First verify that without mocking, current_* works normally.
387-
# Skip this check for CI, terminal, and agent since they may legitimately
388-
# be unknown.
389-
if trait_type not in ("CI", "terminal", "agent"):
392+
# Skip this check for CI, terminal, agent, and shell since they may
393+
# legitimately be unknown (minimal sandboxes often have no recognizable
394+
# shell).
395+
if trait_type not in ("CI", "terminal", "agent", "shell"):
390396
invalidate_caches()
391397
result = current_func()
392398
assert result in all_collection

0 commit comments

Comments
 (0)