stricttest v0.2.0 /python.src.stricttest.config
On this page

Ini-key registration, validation and resolution: the five required safety keys, the closed preservation enum, and the parameterized floor constants.

#python.src.stricttest.config

#python.src.stricttest.config

Ini-file configuration for the stricttest floor.

Every knob lives in [tool.pytest.ini_options] (or pytest.ini / tox.ini / setup.cfg -- anything pytest reads as ini).

Installing the plugin IS adoption: the safety keys below are REQUIRED and a missing one aborts the session at configure time. There are no implicit defaults for the socket stance, the socket allowlists, or the sandbox stance -- a repo must declare where it stands before its suite is allowed to run.

#_Missing

Sentinel default for every ini key.

Presence must be distinguishable from an explicitly-empty value: a project that writes stricttest_socket_allowlist = [] has declared its stance, while one that omits the key has not. Registering this sentinel as each key's default makes getini itself report presence, without reaching for the deprecated config.inicfg.

#Settings

Resolved, validated stricttest configuration for one pytest session.

#add_ini_options

python
def add_ini_options(parser) -> None

Register every stricttest ini key with pytest's parser.

#_present

python
def _present(config, key: str) -> bool

True when key was actually written in the ini file.

#parse_host_port

python
def parse_host_port(entry: str) -> tuple[str, str]

Parse one allowlist entry into (host, port).

Bracketed form [::1]:5432 carries IPv6 literals; the plain form is host:port. Anything else is a configuration error.

#missing_required_keys

python
def missing_required_keys(config) -> list[str]

Return the required ini keys absent from this project's config.

#remediation_block

python
def remediation_block(inipath) -> str

The most-restrictive starting stance, in inipath's own syntax.

A configuration snippet a project cannot paste is not remediation. TOML quotes values and writes lists in brackets; classic ini files take literal unquoted text and one list entry per indented line, so a TOML block pasted into pytest.ini produces a second error instead of a fix.

None (no ini file at all yet) renders TOML, because the file such a project should create is pyproject.toml.

#required_keys_error

python
def required_keys_error(config, missing: list[str]) -> pytest.UsageError

Build the precise configure-time abort for missing safety keys.

#resolve

python
def resolve(config) -> Settings

Validate and resolve the full settings object, or raise UsageError.

Search