Marco Ricci commited on 2026-06-13 21:28:11
Zeige 4 geänderte Dateien mit 25 Einfügungen und 8 Löschungen.
Introduce a second coverage exclusion marker in the form of an overridable session-level fixture `skip_if_no_ctypes_windll_support`, similar to the existing `skip_if_no_af_unix_support` fixture. Also update the description of both fixtures to match their current usage. Also also fix a coverage slipup in a failsafe path of the `AgentProtocolResponseQueue` testing machinery.
| ... | ... |
@@ -271,6 +271,7 @@ exclude_also = [ |
| 271 | 271 |
# exclusions for platform-specific code that will not trigger on POSIX: |
| 272 | 272 |
# |
| 273 | 273 |
# 'pragma: unless the-annoying-os no cover', |
| 274 |
+ # 'skip_if_no_ctypes_windll_support: None,', |
|
| 274 | 275 |
|
| 275 | 276 |
# If running only on The Annoying OS (Microsoft Windows), then you may |
| 276 | 277 |
# want to enable the following exclusions for platform-specific code |
| ... | ... |
@@ -63,10 +63,9 @@ def term_handler() -> Iterator[None]: # pragma: no cover [external] |
| 63 | 63 |
|
| 64 | 64 |
@pytest.fixture(scope="session") |
| 65 | 65 |
def skip_if_no_af_unix_support() -> None: # pragma: no cover [external] |
| 66 |
- """Skip the test if Python does not support AF_UNIX. |
|
| 66 |
+ """Skip the test if Python does not support `AF_UNIX`. |
|
| 67 | 67 |
|
| 68 |
- Implemented as a fixture instead of a mark because it has |
|
| 69 |
- consequences for other fixtures, and because another "autouse" |
|
| 68 |
+ Implemented as a fixture instead of a mark because another "autouse" |
|
| 70 | 69 |
session fixture may want to force/simulate non-support of |
| 71 | 70 |
[`socket.AF_UNIX`][]. |
| 72 | 71 |
|
| ... | ... |
@@ -75,6 +74,21 @@ def skip_if_no_af_unix_support() -> None: # pragma: no cover [external] |
| 75 | 74 |
pytest.skip("No Python or system support for UNIX domain sockets.")
|
| 76 | 75 |
|
| 77 | 76 |
|
| 77 |
+@pytest.fixture(scope="session") |
|
| 78 |
+def skip_if_no_ctypes_windll_support() -> None: # pragma: no cover [external] |
|
| 79 |
+ """Skip the test if Python does not support WinDLL in `ctypes`. |
|
| 80 |
+ |
|
| 81 |
+ Implemented as a fixture instead of a mark because another "autouse" |
|
| 82 |
+ session fixture may want to force/simulate non-support of |
|
| 83 |
+ [`ctypes.WinDLL`][]. |
|
| 84 |
+ |
|
| 85 |
+ """ |
|
| 86 |
+ if not hasattr(ctypes, "WinDLL"): |
|
| 87 |
+ pytest.skip( |
|
| 88 |
+ "No Python or system support for interfacing Windows DLLs." |
|
| 89 |
+ ) |
|
| 90 |
+ |
|
| 91 |
+ |
|
| 78 | 92 |
class SSHAgentSpawnFunc(Protocol): |
| 79 | 93 |
"""Spawns an SSH agent, if possible.""" |
| 80 | 94 |
|
| ... | ... |
@@ -351,7 +351,11 @@ class AgentProtocolResponseQueue: |
| 351 | 351 |
exc_value: BaseException | None, |
| 352 | 352 |
exc_tb: types.TracebackType | None, |
| 353 | 353 |
) -> Literal[False]: |
| 354 |
- if (exc_type, exc_value, exc_tb) != (None, None, None): |
|
| 354 |
+ if (exc_type, exc_value, exc_tb) != ( |
|
| 355 |
+ None, |
|
| 356 |
+ None, |
|
| 357 |
+ None, |
|
| 358 |
+ ): # pragma: no cover [external] |
|
| 355 | 359 |
return False |
| 356 | 360 |
assert not self, f"Agent I/O queue still has contents: {self.queue!r}"
|
| 357 | 361 |
return False |
| ... | ... |
@@ -1481,16 +1481,14 @@ class TestSSHAgentSocketProviderFailures: |
| 1481 | 1481 |
): |
| 1482 | 1482 |
provider() |
| 1483 | 1483 |
|
| 1484 |
- @pytest.mark.skipif( |
|
| 1485 |
- not hasattr(ctypes, "WinDLL"), |
|
| 1486 |
- reason="not relevant to systems without Windows named pipe support", |
|
| 1487 |
- ) |
|
| 1488 | 1484 |
@hypothesis.given(named_pipe_name=Strategies.bad_named_pipe_names()) |
| 1489 | 1485 |
def test_ssh_auth_sock_on_windows_provider_bad_named_pipe_name( |
| 1490 | 1486 |
self, |
| 1491 | 1487 |
named_pipe_name: str, |
| 1488 |
+ skip_if_no_ctypes_windll_support: None, |
|
| 1492 | 1489 |
) -> None: |
| 1493 | 1490 |
"""For `ssh_auth_sock_on_windows`, fail for bad named pipe names.""" |
| 1491 |
+ del skip_if_no_ctypes_windll_support |
|
| 1494 | 1492 |
provider = socketprovider.SocketProvider.resolve( |
| 1495 | 1493 |
"ssh_auth_sock_on_windows" |
| 1496 | 1494 |
) |
| 1497 | 1495 |