pytest 9.1.1
- Source
- https://github.com/pytest-dev/pytest
- Tag scanned
9.1.1- Compared with
9.1.0(0 signals introduced since)- Files
- 560 scanned, 41 skipped (binary, oversized, or unrecognised)
- Signals
- 0 critical · 0 warn · 77 info
- Scan time
- 47.1 s
- LLM review
- Reviewed by claude-haiku-5-5 (Anthropic): 63 of 63 warn and critical signals; 63 demoted to info.
- Disclude version
- 4.1.0
- Scanned (UTC)
- 2026-10-21 21:11
Signals
Ordered by severity, then signals introduced in this release. Hidden characters are shown as ⟨U+…⟩.
-
= assert ==likely benign Documentation example calling os.system with a fixed echo command to demonstrate output capture.Reasoning
Literal os.system call with a fixed echo command inside an rst doc example for capfd. No untrusted input and no obfuscation.
-
= assert == blikely benign Documentation example of os.system with a fixed echo command for binary capture.Reasoning
Same literal echo example in a doc page, illustrating capfdbinary. Nothing malicious.
-
= = =likely benign Demo code compiling a module's source inside a pytest assertion example.Reasoning
Pytest's assertion failure demo builds a module from source text to show import-time rewriting behaviour. The compile is a local demo artifact, not an attack.
-
= =likely benign Demo exec of a dynamically built module in a pytest assertion example.Reasoning
exec of compiled demo source in a pytest example file. The surrounding code is a legitimate import helper for demonstrating failures.
-
info
warn→ info by reviewdynamic-executiondoc/en/example/assertion/test_setup_flow_example.py:16:19=likely benign Test example that uses eval on the method name to set an id.Reasoning
Test example evaluates a slice of the test method name to derive an id. Input comes from the test's own name, so the risk is nil.
-
assert ==likely benign Doc snippet using eval on a test parameter in a parametrize example.Reasoning
Documentation example of eval in a parametrize test, illustrating expression evaluation. Standard tutorial code.
-
assert ==likely benign Doc snippet using eval inside a parametrized test example.Reasoning
Doc snippet of an eval-based parametrized test, repeated tutorial material from the historical notes.
-
likely benign Prose mention of an eval expression in historical notes.
Reasoning
Prose inline literal of eval on a constant string describing old pytest behaviour. It is not executed code.
-
likely benign Install instruction evaluating register-python-argcomplete output for bash completion.
Reasoning
This is the documented way to enable pytest's bash completion, eval of a command substitution from the vendor's own helper. It is dynamic but is the standard, expected setup instruction.
-
assert ==likely benign Doc snippet using eval on a parameter in a parametrize tutorial.Reasoning
Documentation example of eval in a parametrized test. Tutorial code with no malicious indicators.
-
likely benign Doc failure-output excerpt containing an eval line.
Reasoning
Prose or error-output snippet showing the eval line from a test failure. Not executed code.
-
assert ==likely benign Doc snippet using eval in a parametrize example.Reasoning
Same eval-based parametrize example in tutorial docs. Benign.
-
⟨U+00A0⟩ ⟨U+00A0⟩ pytest test_flat.py --capture=no # will not show "setting up"likely benign Non-breaking space characters in an indented doc code block.Reasoning
A non-breaking space in rst indentation is a common editor artifact in docs. It causes at most a rendering quirk and shows no obfuscation.
-
likely benign Cyrillic prose in a plugin description flagged as a homoglyph.
Reasoning
The flagged character is part of ordinary Russian prose in a plugin description, not an identifier. The homoglyph detector misfires on natural-language text.
-
likely benign Russian plugin description text falsely flagged as a homoglyph.
Reasoning
Same Russian description text for the pytest_notify plugin. Legitimate localized prose, not an identifier.
-
returnlikely benign Pytest traceback helper that evaluates code in a frame's namespace.Reasoning
pytest's frame-evaluation helper evaluates expressions in captured frame globals and locals for repr and debugging. This is core, expected functionality of the library.
-
= = =likely benign Dynamic __import__ of a hash module name inside pytest's vendored py.path checksum code.Reasoning
The hashtype value is chosen from a fixed set of hash names (e.g. 'sha', 'md5') before __import__ runs, so this is a standard hashlib fallback with no attacker-controlled input.
-
=likely benign Dynamic __import__ of a module name in pytest's vendored py.path pyimport implementation.Reasoning
This is the import machinery of py.path.pyimport, which imports a module by its computed package name and then reads it from sys.modules. That is the documented purpose of the function, not a hidden payload.
-
dellikely benign exec of a module's own source file during pytest's vendored py.path pyimport.Reasoning
pyimport executes the source of the file the caller explicitly asked to import, into the module's own namespace, and removes the module from sys.modules on failure. The pickle import is incidental to the module-loading logic.
-
dellikely benign exec of a file's contents into a module namespace in pytest's vendored py.path.Reasoning
This is the same legitimate module-source exec in pyimport, run into mod.__dict__ on a file the user specified. The finding is a duplicate of the decoder-import-with-exec signal on the same line.
-
likely benign exec of cached rewritten bytecode in pytest's assertion rewrite import hook.
Reasoning
This executes a cached rewritten bytecode object into the module's dict, which is how pytest's assertion rewriting hook loads its modules. Marshal and exec in this position are expected for a bytecode import hook.
-
likely benign exec of a code object from pytest's assertion rewrite cache.
Reasoning
This is the same exec of cached rewritten bytecode in the assertion rewrite hook, a duplicate signal on one line of standard import machinery.
-
= return ,likely benign compile of a rewritten AST for an assertion-rewritten test module.Reasoning
This compiles an AST produced by pytest's own assertion rewriter from the test module's source. The compile call is the normal final step of that rewriting.
-
=likely benign marshal.load of pytest's cached .pyc bytecode in _read_pyc.Reasoning
marshal.load reads pytest's own .pyc cache files, which are written locally by the same tool. Marshal deserialization is a general concern, but this is the standard bytecode cache read path.
-
# testing/test_config.py::test_disable_plugin_autoload. =likely benign Dynamic __import__ of a configured plugin module in pytest's config plugin loader.Reasoning
This imports a plugin module named by the user's configured plugin spec, then reads it from sys.modules. Plugin loading by name is the design of pytest's plugin manager.
-
= = , ,likely benign sys._getframe used to locate the caller for pytest warning records.Reasoning
sys._getframe with a stacklevel offset is how pytest attributes a warning to the caller's file and line. It is ordinary diagnostic use of frame introspection.
-
"""Invoke debugging via ``Pdb.set_trace``, dropping any IO capturing.""" = . =likely benign sys._getframe().f_back used to start pdb at the caller's frame in pytest's debugging module.Reasoning
This takes the calling frame so that pdb.set_trace starts at the user's breakpoint location, which is the expected behaviour of pytest's pdb integration.
-
= = =likely benign inspect.stack used to get the defining file of a fixture for pytest's fixture registry.Reasoning
inspect.stack is used to find the file and location where a fixture is defined, for error reporting and path resolution. It is a common and benign introspection pattern.
-
= =likely benign compile of a parsed pytest -k/-m match expression.Reasoning
This compiles the AST produced by pytest's own -k/-m expression parser, with a fixed filename. It is the intended compile step of a small expression language.
-
""" return bool(eval(self._code, {"__builtins__": {}}, MatcherAdapter(matcher)))likely benign Restricted eval of a compiled pytest mark expression with builtins disabled.Reasoning
eval runs with an empty __builtins__ dict and only a matcher adapter in scope. This sandboxes the expression to name lookups for keyword matching, so it is restricted evaluation rather than arbitrary code execution.
-
= True # to catch syntaxerrors # Keep the public signature compatible while using the pytest 9.1 default behavior.dismissed pytest's outcomes module compiles a module-name string to catch syntax errors.Reasoning
The compile call validates the syntax of a module-name string in pytest's skip/importorskip helper, with a comment saying so. It is a standard syntax-check pattern in a test framework, not obfuscation or a dropper.
-
# Since Python 3.13, f_locals is not a dict, but eval requires a dict. = , =dismissed Pytester helper takes the caller's frame locals to evaluate user-supplied match expressions.Reasoning
pytester's matchreport helper reads the caller's locals via sys._getframe(1) so that assertion expressions can be evaluated against them. The 'critical' severity comes from the anti-analysis heuristic firing on any file that mentions eval, which is a false positive here.
-
dismissed Pytester evaluates test-supplied check expressions against recorded hook call attributes.
Reasoning
eval runs test-author-written check expressions against a call's attributes inside a testing utility. This is intended assertion-matching behaviour for a test framework, not attacker-controlled execution.
-
= f = =dismissed pytest's skipif evaluator compiles mark condition strings as expressions.Reasoning
pytest compiles skipif/xfail condition strings from marks, which is the documented feature of evaluating condition expressions. The code is in the framework's marker evaluation path and handles SyntaxError explicitly.
-
= = =dismissed pytest evaluates compiled skipif/xfail condition expressions from markers.Reasoning
This eval runs the compiled skip/xfail condition from the test author's marks, which is the documented behaviour of pytest's condition-based markers. It is the expected use of eval in this context.
-
return =dismissed Test helper returns its own frame to exercise pytest's Frame wrapper.Reasoning
This is a unit test that uses sys._getframe(0) to construct a Frame object for testing pytest's code-introspection wrapper. The anti-analysis label is a false positive from the file also containing exec/eval.
-
return =dismissed Test helper returns its own frame to exercise pytest's Frame wrapper.Reasoning
Same pattern as the other frame tests: a test function returns its own frame to check pytest's Frame class. Benign test code.
-
return =dismissed Test function returns its own frame to test argument extraction from frames.Reasoning
A parametrised-signature test helper returns its own frame for Frame introspection tests. This is ordinary test scaffolding.
-
return =dismissed Test function returns its own frame to test *args handling in Frame.Reasoning
A test helper with *args returns its own frame to test argument extraction. Benign test code.
-
return =dismissed Test function returns its own frame to test **kwargs handling in Frame.Reasoning
A test helper with **kwargs returns its own frame to test keyword-argument extraction. Benign test code.
-
return =dismissed Test function returns its own frame to test combined varargs handling in Frame.Reasoning
A test helper with *args and **kwargs returns its own frame to test argument extraction. Benign test code.
-
=dismissed Test executes a compiled code object to produce a traceback for ExceptionInfo.Reasoning
The exec of a compiled code object sits inside a test that checks how pytest's ExceptionInfo handles tracebacks from exec'd code. It is an intentional test fixture, not a dropper.
-
=dismissed Test executes a compiled code object to produce a traceback for ExceptionInfo.Reasoning
Same as the other exec in this file: a test builds a traceback from compiled code to verify ExceptionInfo behaviour. Benign.
-
nonlocal = . assert is not Nonedismissed Test inspects the upper frame's function name to verify traceback behaviour.Reasoning
The test reads its caller's frame to check the co_name of the function that raised an error. This is a normal test assertion about traceback paths.
-
= = .likely benign Test helper using sys._getframe to capture the calling frame's statement.Reasoning
This is pytest's own test suite for source-code inspection helpers. sys._getframe is used to capture the caller's statement, which is a normal pattern for a Source/getstatement helper. The anti-analysis label is a heuristic match on the file's test fixtures.
-
= =likely benign Test compiles a fixture source string to exercise source lookup.Reasoning
Compiling a test string constructed with known contents inside pytest's source-inspection tests is expected; the code is test fixture data, not attacker-controlled.
-
: = , = assert is not Nonelikely benign Test evaluates a locally compiled fixture code object.Reasoning
eval of a code object compiled from a local test fixture, in pytest's test suite. Benign test scaffolding.
-
= = .likely benign Test helper capturing caller frame via sys._getframe.Reasoning
Same pytest source-inspection helper pattern as the earlier frame introspection finding; a legitimate test utility.
-
= 99 return # fmt: onlikely benign Test wrapper compiling a constant-built source string to check line numbers.Reasoning
Test helper that pads source lines with a fixed number of newlines to test line-number handling; the string is built from constants, not external input.
-
likely benign Conftest restores the previous sys trace function after a test.
Reasoning
Restoring the original trace function in a pytest conftest fixture is a standard way to avoid leaking debugger/coverage tracing between tests.
-
info
identifier-low-lengthtesting/example_scripts/dataclasses/test_compare_recursive_dataclasses.py:1:1 -
=likely benign Build helper invoking pyinstaller through a shell with locally assembled arguments.Reasoning
Build script for freezing test executables with pyinstaller; the command is assembled from fixed local arguments and shell=True is used only to run the local build tool. Not attacker-driven, though shell=True is worth noting.
-
+=likely benign Runs the frozen test executable via os.system during tox tests.Reasoning
Test-freezing helper running the built executable with a fixed f-string command; a normal test runner invocation.
-
= assert == 21 # 5*2 + 1 + 5*2 -
= assert == 21 # 5*2 + 1 + 5*2 -
-
-
-
-
-
= assert == ==likely benign Test evaluates a repr string to verify round-trip formatting.Reasoning
Test for ExceptionGroup repr/str checks that evals a repr-like string in a parametrized test; it's test scaffolding over fixed inputs.
-
= = : =likely benign Test helper compiling and executing rewritten assertion source.Reasoning
The assertion-rewrite test helper compiles and execs rewritten test source, which is how pytest tests its own rewriting. The marshal import is a normal part of pytest's pyc caching machinery, not a payload loader.
-
= = : =likely benign Compiles the rewritten test module source.Reasoning
Compile of rewritten test module source inside pytest's assertion-rewrite tests; expected behaviour.
-
=likely benign Execs the compiled test code in a test namespace.Reasoning
Executes the compiled rewritten test source in a namespace to run the test function; standard for testing the rewriter.
-
= assert =likely benign Test helper walks to the caller frame to check reported locations.Reasoning
inspect.currentframe used to report the caller's line in an assertion-rewrite test helper; ordinary introspection in test code.
-
= = =likely benign Test compiles rewritten source to verify assertion locations.Reasoning
Rewrites and compiles test source strings in pytest's assertion-rewrite tests; expected for this test module.
-
= = =likely benign Test execs the rewritten source in globals.Reasoning
Executes compiled rewritten test source in the test's globals; standard test scaffolding.
-
= =likely benign Test compiles source to compare original assertion locations.Reasoning
Compiles a test source string to compare original locations in the rewriter test; expected.
-
= =likely benign Test helper that execs a compiled module during assertion-rewrite testing.Reasoning
The file is pytest's own test suite for assertion rewriting. The exec call runs a module compiled from a test-generated source string with explicit globals, which is the expected way to test an import hook. The snippet shows no encoded payload, network access, or obfuscation.
-
= # Good header.likely benign Test code compiles source bytes and marshals them to exercise pyc generation.Reasoning
This is a test that marshals a compiled code object to check the pyc writer. Compiling a test-supplied source is a normal pattern in this test suite, and the snippet has no suspicious indicators.
-
""" >>> name = 'с' # not letter 'c' but instead Cyrillic 's'. 'anything' """ -
, , , , -
., ]dismissed Test fixture using a deliberately mixed-script identifier to exercise unicode mark names.Reasoning
The identifier mixes Latin and Hebrew deliberately, and the line carries a pylint disable for non-ascii-name. This is a test fixture checking that the mark-expression parser handles unicode identifiers. It is not a homoglyph attack on real code, and the raw-pass finding has a high false-positive rate.
-
., ] -
, , , , -
, , , , -
, , , ,
Reproduce This Scan
Run disclude locally to verify. Add --format sarif for SARIF output. Add --llm (with an API key in the environment) to include the LLM review.
&&