PyTest - sgml/signature GitHub Wiki
Pytest Combined Defaults FAQ (Runtime + Config, Default‑First With Inline Definitions)
What is the default behavior of a fixture name in pytest?
A fixture name, which is the identifier pytest uses to inject a fixture (a reusable test dependency) into tests, defaults to the Python function name. It can be overridden with @pytest.fixture(name="...").
What is the default behavior of fixture scope in pytest?
Fixture scope, which determines how long a fixture instance lives and how often it is reused, defaults to function. It can be changed to session, package, module, or class.
What is the default behavior of autouse fixtures in pytest?
Autouse fixtures, which are fixtures that run automatically for every test without being requested by name, default to autouse=False. They can be enabled with autouse=True.
What is the default behavior of fixture parameters in pytest?
Fixture parameters, which allow a fixture to run multiple times with different values, default to params=None. They can be set with params=[...].
What is the default behavior of fixture parameter IDs in pytest?
Fixture parameter IDs, which are the human‑readable labels pytest assigns to parametrized test cases, default to the string representation of each parameter. They can be overridden with ids=[...] or ids=callable.
What is the default behavior of fixture teardown in pytest?
Fixture teardown, which is the cleanup logic executed after a fixture’s scope ends, is not present by default. It appears only when using yield or request.addfinalizer.
What is the default behavior of fixture execution frequency in pytest?
Fixture execution frequency, which determines how often a fixture is created, defaults to once per test for the function scope.
What is the default behavior of fixture ordering in pytest?
Fixture ordering, which is the sequence in which fixtures are set up, is determined by the dependency graph. Independent fixtures have no guaranteed order.
What is the default behavior of fixture lookup in pytest?
Fixture lookup, which is pytest’s process for resolving a fixture name to a fixture definition, follows this order: test function → test module → parent conftest.py files → builtin fixtures → plugin fixtures.
What is the default behavior of missing fixture handling in pytest?
Missing fixture handling, which is how pytest responds when a fixture name cannot be resolved, raises a FixtureLookupError. This can be avoided by skipping or xfail inside a fixture.
What is the default behavior of builtin fixtures in pytest?
Builtin fixtures, which are fixtures provided automatically by pytest, include tmp_path, tmp_path_factory, monkeypatch, capsys, capfd, caplog, recwarn, pytestconfig, and request.
What is the default behavior of fixture injection in pytest?
Fixture injection, which is pytest’s name‑based dependency injection system, defaults to matching fixture names to test function parameters. It can be overridden with aliasing or request.getfixturevalue.
What is the default behavior of fixture teardown timing in pytest?
Fixture teardown timing, which determines when cleanup occurs, defaults to running at the end of the fixture’s scope.
What is the default behavior of test discovery in pytest?
Test discovery, which is pytest’s mechanism for locating tests, defaults to files named test_*.py or *_test.py, classes named Test*, and functions named test_*.
What is the default behavior of the test collection root in pytest?
The test collection root, which is the directory pytest treats as the project root, is auto‑detected based on the first parent containing a config file or VCS directory.
What is the default behavior of collection error handling in pytest?
Collection error handling, which determines how pytest reacts to errors during test discovery, defaults to failing the session.
What is the default behavior of assertion rewriting in pytest?
Assertion rewriting, which is pytest’s enhancement of Python assert statements to provide detailed introspection, is enabled by default.
What is the default behavior of assertion introspection in pytest?
Assertion introspection, which is pytest’s detailed explanation of assertion failures, is enabled by default.
What is the default behavior of test execution order in pytest?
Test execution order, which is the sequence in which tests run, defaults to file order.
What is the default behavior of test failure handling in pytest?
Test failure handling, which determines how pytest proceeds after a failure, defaults to continuing the session.
What is the default behavior of traceback formatting in pytest?
Traceback formatting, which controls how error stack traces are displayed, defaults to auto.
What is the default behavior of warning handling in pytest?
Warning handling, which determines how pytest processes Python warnings, defaults to treating PytestUnhandledCoroutineWarning and PytestReturnNotNoneWarning as errors.
What is the default behavior of output capturing in pytest?
Output capturing, which intercepts stdout and stderr during tests, is enabled by default.
What is the default behavior of logging capture in pytest?
Logging capture, which intercepts Python logging output, is enabled only for failures by default.
What is the default behavior of skipping in pytest?
Skipping, which marks tests as intentionally not run, occurs only when tests are explicitly marked.
What is the default behavior of xfail in pytest?
Xfail, which marks tests as expected to fail, defaults to non‑strict mode.
What is the default behavior of marker handling in pytest?
Marker handling, which governs how pytest interprets test markers, defaults to accepting all markers without validation.
What is the default behavior of plugin autoloading in pytest?
Plugin autoloading, which automatically loads installed pytest plugins, is enabled by default.
What is the default behavior of environment variable handling in pytest?
Environment variable handling, which determines how pytest interacts with environment variables, defaults to leaving them unchanged except for internal use.
What is the default behavior of temporary directory creation in pytest?
Temporary directory creation, which provides per‑test and per‑session temp paths, defaults to using tmp_path and tmp_path_factory.
What is the default behavior of test reporting in pytest?
Test reporting, which summarizes test outcomes, defaults to printing failures, errors, and skips.
What is the default behavior of exit codes in pytest?
Exit codes, which communicate session results, default to: 0 success, 1 failures, 2 usage errors, 3 internal errors, 4 no tests collected.
What is the default behavior of parametrization in pytest?
Parametrization, which generates multiple test cases from one test function, defaults to using repr‑based IDs.
What is the default behavior of hook execution in pytest?
Hook execution, which allows plugins and conftests to extend pytest, defaults to no‑op implementations.
What is the default behavior of test selection in pytest?
Test selection, which determines which tests run, defaults to running all discovered tests.
What is the default behavior of import mode in pytest?
Import mode, which controls how pytest imports test modules, defaults to importlib.
What is the default behavior of path resolution in pytest?
Path resolution, which determines how pytest modifies sys.path, defaults to adding the project root.
What is the default behavior of test retries in pytest?
Test retries, which rerun failing tests, are not enabled by default.
What is the default behavior of parallel execution in pytest?
Parallel execution, which runs tests concurrently, is not enabled by default.
What is the default behavior of doctest execution in pytest?
Doctest execution, which runs examples embedded in documentation, is disabled by default.
What is the default behavior of keyboard interrupt handling in pytest?
Keyboard interrupt handling, which determines how pytest responds to Ctrl‑C, defaults to stopping the session.
What is the default behavior of internal caching in pytest?
Internal caching, which stores run metadata, defaults to writing to .pytest_cache.
What is the default behavior of duration reporting in pytest?
Duration reporting, which identifies slow tests, is disabled by default.
What is the default behavior of fail‑fast in pytest?
Fail‑fast, which stops the session after the first failure, is disabled by default.
What is the default behavior of keyword filtering in pytest?
Keyword filtering, which selects tests by substring match, is disabled by default.
What is the default behavior of marker filtering in pytest?
Marker filtering, which selects tests by marker expression, is disabled by default.
What is the default behavior of test reruns in pytest?
Test reruns, which repeat failing tests, are not enabled by default.
What is the default behavior of session start in pytest?
Session start, which initializes pytest’s runtime environment, defaults to loading plugins, discovering tests, and beginning execution.
What is the default behavior of session finish in pytest?
Session finish, which finalizes pytest’s runtime environment, defaults to running teardown hooks, fixture teardowns, and printing a summary.
Configuration Defaults
What is the default behavior of the addopts setting in pytest?
The addopts setting, which adds default command‑line options, defaults to an empty string.
What is the default behavior of ignored directories in pytest?
Ignored directories, which pytest excludes from test discovery, default to .*, build, dist, CVS, _darcs, {arch}, *.egg, venv, .venv.
What is the default behavior of console output style in pytest?
Console output style, which controls how test results are displayed, defaults to classic.
What is the default behavior of the cache directory in pytest?
The cache directory, which stores internal pytest metadata, defaults to .pytest_cache.
What is the default behavior of the logging level in pytest?
The logging level, which controls the minimum severity of captured logs, defaults to WARNING.
What is the default behavior of the log format in pytest?
The log format, which controls how log messages are formatted, defaults to '%(levelname)s:%(name)s:%(message)s'.
What is the default behavior of the log date format in pytest?
The log date format, which controls timestamp formatting in logs, defaults to '%Y-%m-%d %H:%M:%S'.
What is the default behavior of CLI logging in pytest?
CLI logging, which emits log output directly to the terminal during test execution, is disabled by default.
What is the default behavior of the CLI log level in pytest?
The CLI log level, which controls the minimum severity of logs shown in the terminal, defaults to WARNING.
What is the default behavior of the CLI log format in pytest?
The CLI log format, which formats log messages printed to the terminal, defaults to '%(levelname)s:%(name)s:%(message)s'.
What is the default behavior of the CLI log date format in pytest?
The CLI log date format, which timestamps CLI log messages, defaults to '%Y-%m-%d %H:%M:%S'.
What is the default behavior of the file log level in pytest?
The file log level, which controls the minimum severity of logs written to a file, defaults to WARNING.
What is the default behavior of the file log format in pytest?
The file log format, which formats log messages written to a file, defaults to '%(levelname)s:%(name)s:%(message)s'.
What is the default behavior of the file log date format in pytest?
The file log date format, which timestamps file log messages, defaults to '%Y-%m-%d %H:%M:%S'.
What is the default behavior of test file patterns in pytest?
Test file patterns, which determine which files pytest treats as test modules, default to test_*.py and *_test.py.
What is the default behavior of test class patterns in pytest?
Test class patterns, which determine which classes pytest treats as test containers, default to Test*.
What is the default behavior of test function patterns in pytest?
Test function patterns, which determine which functions pytest treats as tests, default to test_*.
What is the default behavior of test ID escaping in pytest?
Test ID escaping, which controls how pytest escapes characters in test identifiers, defaults to being enabled.
What is the default behavior of warning filters in pytest?
Warning filters, which determine how pytest handles warnings, default to treating two pytest‑specific warnings as errors.
What is the default behavior of strict xfail in pytest?
Strict xfail, which treats unexpected passes as failures, is disabled by default.
What is the default behavior of the assertion pass hook in pytest?
The assertion pass hook, which allows plugins to react to passing assertions, is disabled by default.
What is the default behavior of doctest option flags in pytest?
Doctest option flags, which configure doctest behavior, default to 0.
What is the default behavior of doctest encoding in pytest?
Doctest encoding, which determines how doctest files are read, defaults to utf-8.
What is the default behavior of doctest file patterns in pytest?
Doctest file patterns, which determine which files pytest treats as doctest sources, default to *.txt.
What is the default behavior of doctest import‑error handling in pytest?
Doctest import‑error handling, which determines whether import errors inside doctests are ignored, defaults to not ignoring them.
What is the default behavior of doctest failure continuation in pytest?
Doctest failure continuation, which determines whether doctest execution continues after a failure, defaults to stopping.
What is the default behavior of traceback style in pytest?
Traceback style, which controls how stack traces are formatted, defaults to auto.
What is the default behavior of duration reporting in pytest?
Duration reporting, which identifies slow tests, defaults to being disabled.
What is the default behavior of the minimum duration threshold in pytest?
The minimum duration threshold, which filters which tests count as slow, defaults to 0.005 seconds.
What is the default behavior of showing locals in pytest?
Showing locals, which includes local variables in tracebacks, is disabled by default.
What is the default behavior of verbosity in pytest?
Verbosity, which controls the amount of output pytest prints, defaults to 0.
What is the default behavior of random order buckets in pytest?
Random order buckets, which group tests for randomization, default to module.
What is the default behavior of the JUnit suite name in pytest?
The JUnit suite name, which labels the test suite in JUnit XML output, defaults to pytest.
What is the default behavior of JUnit logging in pytest?
JUnit logging, which includes log output in JUnit XML, defaults to no.
What is the default behavior of logging passing tests in JUnit in pytest?
Logging passing tests in JUnit, which includes successful tests in JUnit XML logs, is disabled by default.
What is the default behavior of JUnit duration reporting in pytest?
JUnit duration reporting, which controls how test durations appear in JUnit XML, defaults to total.
What is the default behavior of the JUnit family setting in pytest?
The JUnit family setting, which determines the XML schema version, defaults to xunit2.
What is the default behavior of branch coverage in pytest?
Branch coverage, which measures branch execution in coverage reports, is disabled by default.
What is the default behavior of the coverage fail‑under threshold in pytest?
The coverage fail‑under threshold, which enforces minimum coverage, defaults to 0.
What is the default behavior of coverage reporting in pytest?
Coverage reporting, which determines output formats, defaults to term.
What is the default behavior of skipping covered files in pytest?
Skipping covered files, which hides fully covered files in coverage reports, is disabled by default.
What is the default behavior of skipping empty files in pytest?
Skipping empty files, which hides files with no executable code, is disabled by default.
What is the default behavior of the faulthandler timeout in pytest?
The faulthandler timeout, which triggers stack dumps on hangs, defaults to 0.
What is the default behavior of strict config mode in pytest?
Strict config mode, which enforces validation of config keys, is disabled by default.
What is the default behavior of strict markers in pytest?
Strict markers, which require markers to be declared, are disabled by default.