|
78 | 78 | is_linux, |
79 | 79 | is_macos, |
80 | 80 | is_ubuntu, |
| 81 | + is_unknown_shell, |
81 | 82 | is_windows, |
82 | 83 | platform_data as platform_data_module, |
83 | 84 | shell_data as shell_data_module, |
@@ -270,8 +271,12 @@ def test_current_funcs(): |
270 | 271 | current_traits_results = current_traits() |
271 | 272 | assert ALL_TRAITS.issuperset(current_traits_results) |
272 | 273 |
|
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 |
275 | 280 | # Terminal is optional: headless/CI environments may not have one. |
276 | 281 | if is_any_terminal(): |
277 | 282 | detected_traits += 1 |
@@ -307,9 +312,9 @@ def test_current_funcs(): |
307 | 312 | assert current_platform_result is not UNKNOWN_PLATFORM |
308 | 313 |
|
309 | 314 | 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 |
313 | 318 |
|
314 | 319 | current_terminal_result = current_terminal() |
315 | 320 | assert current_terminal_result in ALL_TERMINALS | {UNKNOWN_TERMINAL} |
@@ -384,9 +389,10 @@ def test_current_strict_mode( |
384 | 389 | ): |
385 | 390 | """Test that ``current_*(strict=True)`` raises an error when unrecognized.""" |
386 | 391 | # 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"): |
390 | 396 | invalidate_caches() |
391 | 397 | result = current_func() |
392 | 398 | assert result in all_collection |
|
0 commit comments