tests.conftest module¶
Fixtures, configuration and helpers for tests.
- tests.conftest.httpserver_listen_address()[source]¶
Bind the local HTTP server to the loopback address, not to a name.
Overrides
pytest-httpserver’s default of("localhost", 0). Resolving that name is the one thing thetests/test_config.pycases serving a configuration file over HTTP need from the host, and a build sandbox is exactly where it is unavailable: the Nix one on macOS denies the lookup, so every one of them errors out withsocket.gaierror: [Errno 8] nodename nor servname provided, or not known.Binding the literal address asks nothing of the resolver. Whether a sandbox additionally gates the loopback socket is its own policy, and a separate question: this only removes the lookup that failed first.
- tests.conftest.requires_process_table()[source]¶
Skip a test where the process table does not list the test’s own process.
The kill paths of
run_clifind a command’s descendants in the process table. Linux reads it from/proc. Elsewhere it comes fromps, which a build sandbox can deny: the MacPorts test phase gets an empty listing, so the kill tests would fail on what the sandbox hides rather than on the code.The probe runs
psitself instead of_posix_process_table(), so a regression that empties the table still fails those tests.
- tests.conftest.skip_windows_colors = MarkDecorator(mark=Mark(name='skipif', args=(<extra_platforms.pytest._DeferredCondition object>,), kwargs={'reason': 'Click overstrip colors on Windows'}))¶
Skips color tests on Windows as
click.testing.invokeoverzealously strips colors.See: - https://github.com/pallets/click/issues/2111 - https://github.com/pallets/click/issues/2110
- tests.conftest.TRANSIENT_STATUS_CODES = frozenset({408, 425, 429, 500, 502, 503, 504})¶
Status codes a host answers with when it is refusing this request rather than reporting something about the resource: a rate limit, a proxy hiccup, or a service that is briefly down.
- tests.conftest.fetch_or_skip(url, timeout=60)[source]¶
Fetch
url, skipping the test when the failure says nothing about it.A network-dependent test asserts something about what a host serves. It cannot assert it while the host is rate-limiting, timing out, or down, and a bare
assert response.okthere reportsassert False: a red run that looks like the finding the test exists to make, with nothing naming the cause. GitHub throttles anonymous archive downloads, so a full-suite run hits this on its own schedule and reads as an order-dependent flake.A response that is about the resource still fails, loudly and with its status: a 404 means the URL these tests build no longer resolves, which is the finding, not the weather.
- Return type:
Response
- tests.conftest.walk_commands(command, ctx=None, path=())[source]¶
Yield every
(path, command)pair undercommand, itself included.pathholds the subcommand names leading to the command, the root’s own name excluded, so joining it names the invocation a user would type.- Parameters:
- Return type:
- class tests.conftest.TTYStringIO(initial_value='', newline='\n')[source]¶
Bases:
StringIOAn in-memory text buffer that claims to be an interactive terminal.
- class tests.conftest.StallingTTY[source]¶
Bases:
TTYStringIOA terminal whose writes block once
stallis set, untilreleaseis.Stands in for a terminal paused by flow control (Ctrl+S), or a full pipe.