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
- 559 scanned, 42 skipped (binary, oversized, or unrecognised)
- Signals
- 0 critical · 0 warn · 77 info
- Scan time
- 48.4 s
- LLM review
- Reviewed by claude-haiku-5-5 (Anthropic): 63 of 63 warn and critical signals; 63 demoted to info.
- Disclude version
- 4.0.0
- Scanned (UTC)
- 2026-10-14 18:13
Signals
Ordered by severity, then signals introduced in this release. Hidden characters are shown as ⟨U+…⟩.
-
= assert ==likely benign A documented pytest example calling os.system('echo "hello"') to demonstrate output capture.Reasoning
This is a documentation example of a pytest test using os.system with a fixed echo command to show capfd capturing. The literal command is harmless and the context is clearly illustrative.
-
= assert == blikely benign A second documented pytest example running a fixed os.system echo to demonstrate binary capture.Reasoning
Same pattern as the sibling finding: a fixed echo command in a capfdbinary doc example, with no external input and no malicious behavior.
-
= = =likely benign A demo helper that compiles a source string into a module for assertion-failure illustration.Reasoning
This is pytest's assertion failure demo, which intentionally loads a generated module from a source string to show rewriting behavior. The compile is part of a demo, not a hidden payload.
-
= =likely benign Executes the demo module code it just compiled, as part of the assertion failure example.Reasoning
The exec runs the code produced by the demo's own compile step inside a module namespace it created, as part of the demonstration. Nothing here fetches or hides code from outside the example.
-
info
warn→ info by reviewdynamic-executiondoc/en/example/assertion/test_setup_flow_example.py:16:19=likely benign An example test class using eval on the test method name to set an id.Reasoning
This is a test example that derives an id by evaluating a slice of the method name. It is a contrived but harmless illustration in a documentation test file.
-
assert ==likely benign A doc snippet using eval on parametrized test input.Reasoning
Documentation of pytest parametrization showing eval of test input strings as a teaching example. It is not run against untrusted input.
-
assert ==likely benign A historical docs example using eval on test input.Reasoning
Historical doc example of parametrized eval-based tests. The code is illustrative and inert.
-
dismissed Inline prose mentioning eval of a version check string.
Reasoning
The match is inside prose describing an eval expression in inline markup, not executable code.
-
likely benign Documented instruction to eval the output of register-python-argcomplete for bash completion.
Reasoning
This is the documented install step for pytest's shell completion, eval of a command substitution from the official register-python-argcomplete tool. It is a common pattern and is the expected usage, though it does execute generated shell code.
-
assert ==likely benign A how-to docs example using eval on test input.Reasoning
Standard pytest doc example of eval on parametrized input in a code block. Illustrative only.
-
dismissed Doc output fragment that includes eval in an assertion line.
Reasoning
The match is a doc output/traceback fragment showing an assertion failure, not executable code.
-
assert ==likely benign A repeated docs example using eval on test input.Reasoning
Another instance of the same illustrative eval-based parametrize example in pytest documentation.
-
⟨U+00A0⟩ ⟨U+00A0⟩ pytest test_flat.py --capture=no # will not show "setting up"likely benign A non-breaking space appears in the indentation of a shell example in the plugin docs.Reasoning
A non-breaking space in indentation of an RST example block is a common copy-paste or editor artifact in docs. It is a formatting issue, not an attack, though it is a minor anomaly worth cleaning up.
-
dismissed Cyrillic letter in a Russian-language plugin description in the pytest plugin list docs.
Reasoning
The flagged character is a Cyrillic 'о' inside Russian prose in a plugin description, not inside an identifier or code. Homoglyph checks fire on natural-language text in a non-English docs file, so this is a false positive.
-
dismissed Cyrillic letter in a Russian-language description of the pytest_notify plugin.
Reasoning
Same as the other finding: a Cyrillic 'о' in the Russian description text of the pytest_notify plugin entry. It is ordinary localized prose, not a spoofed identifier.
-
returndismissed eval on a code string inside pytest's frame-evaluation helper.Reasoning
This is pytest's Traceback/Frame.eval, which evaluates a caller-supplied expression in a frame's globals and locals. That is its documented purpose for debugging and assertion introspection, not a hidden payload.
-
= = =dismissed Dynamic __import__ selecting a hashlib module for file hashing in the vendored py.path code.Reasoning
__import__ is called with a hash-type name chosen from a fixed set (sha, md5 variants) to load the hashlib module for computing file checksums. The dynamic name is limited to known hashing modules, so this is a benign pattern.
-
=dismissed Dynamic __import__ of a package module name inside the vendored py.path pyimport routine.Reasoning
This is the pyimport implementation of py.path, which imports a module by name derived from the file's package path. Dynamic import is the mechanism of that API, and the module name comes from the local filesystem layout.
-
dellikely benign Manual module load that reads a source file and execs it into a module namespace in py.path.pyimport.Reasoning
The file reads a .py source file and executes it in a module's __dict__, reimplementing import for pyimport. The 'pickle' decoder-import signal is spurious here, since the code path loads Python source rather than pickled payloads. Executing a module the user asked to import is the intended behavior, though this is a legitimate but sensitive import mechanism.
-
dellikely benign Exec of a module file's contents into its module namespace in py.path.pyimport.Reasoning
Same exec of a module file's bytes into mod.__dict__ as the paired finding. It is the module-loading implementation of py.path, with the pickle decoder signal being a false match.
-
dismissed Execution of a cached rewritten code object into a module's namespace in pytest's assertion rewriter.
Reasoning
pytest's assertion rewriter loads a cached rewritten .pyc through marshal and execs the code object into the module dict. This is standard import-hook behavior; the marshal signal reflects the normal pyc mechanism, not a dropper.
-
dismissed Exec of a cached rewritten code object in pytest's assertion rewriter.
Reasoning
Duplicate of the exec of cached rewritten bytecode in the assertion rewriter. It is the expected loader step for pytest's pyc cache.
-
= return ,dismissed compile of the rewritten AST for test modules in pytest's assertion rewriter.Reasoning
compile is applied to an AST produced by pytest's own assertion-rewriting transform of the test module's source. Compiling the rewritten tree is the core function of the rewriter.
-
=likely benign marshal.load of a cached pyc file in pytest's assertion rewriter's read path.Reasoning
marshal.load reads pytest's own .pyc cache file for rewritten test modules. Deserializing marshal data from a local cache is a known trust-boundary concern, but this is the standard bytecode cache path, not an obfuscated payload.
-
# testing/test_config.py::test_disable_plugin_autoload. =likely benign Imports a pytest plugin module by name during plugin loading.Reasoning
This is the standard pytest plugin import path, where importspec is a module name from entry points or the -p option. It is a non-literal import by design, and the surrounding code handles ImportError and sys.modules lookup as expected.
-
= = , ,likely benign Reads the caller's frame to attach file and line location to a recorded warning.Reasoning
sys._getframe(stacklevel - 1) is used to record the source location for a pytest warning, a common pattern for attributing warnings to the calling code. It only reads filename, line number and function name.
-
"""Invoke debugging via ``Pdb.set_trace``, dropping any IO capturing.""" = . =likely benign Gets the caller's frame so pdb can start a trace there.Reasoning
This is the implementation of pytest.set_trace, which deliberately grabs the caller's frame to start pdb at that point. That is the documented purpose of the function.
-
= = =likely benign Inspects the call stack to find the source file of a fixture definition.Reasoning
inspect.stack()[3] is used to locate the file where a fixture is defined, so pytest can report its source path. This is a normal introspection pattern for test frameworks.
-
= =likely benign Compiles the parsed -k/-m match expression into a code object.Reasoning
This compiles an AST built by pytest's own expression parser for -k and -m matching. The input is the parsed expression AST, not arbitrary attacker-controlled code, and the filename is a fixed label.
-
""" return bool(eval(self._code, {"__builtins__": {}}, MatcherAdapter(matcher)))likely benign Evaluates the compiled -k/-m expression against test names and marks with no builtins.Reasoning
eval runs the compiled match expression with __builtins__ emptied and only a matcher adapter as locals. This is a restricted evaluator for user-supplied -k/-m expressions, which is the intended design.
-
= True # to catch syntaxerrors # Keep the public signature compatible while using the pytest 9.1 default behavior.likely benign Compiles a string solely to validate its syntax, discarding the result.Reasoning
compile(modname, '', 'eval') is used only to raise SyntaxError for an invalid module name, and the result is discarded. The comment confirms that purpose.
-
# Since Python 3.13, f_locals is not a dict, but eval requires a dict. = , =likely benign Copies the caller's frame locals so test check expressions can be evaluated against recorded calls.Reasoning
pytester's LineMatcher-style helper copies the caller's locals to evaluate check expressions in test-assertion helpers. The critical severity comes from the anti-analysis heuristic matching on sys.exit/eval in the same file, not from any evasive behavior. The code is test-support tooling.
-
likely benign Evaluates a check expression against recorded call attributes in pytester.
Reasoning
This evaluates test-author-supplied check expressions against recorded call objects inside a pytester helper. It is test tooling run on the developer's own test code, not a hidden payload.
-
= f = =likely benign Compiles a skipif/xfail string condition from a test mark.Reasoning
This compiles string skipif/xfail conditions, which pytest documents as a feature. The condition comes from the test author's marks and is evaluated in a controlled globals dict.
-
= = =likely benign Evaluates a skipif/xfail string condition from a test mark.Reasoning
This evaluates the compiled skipif/xfail condition, which is the documented string-condition feature of pytest. It is the same code path as the compile call above.
-
return =likely benign Test helper that returns the current frame to exercise the Frame wrapper class.Reasoning
This is a unit test that calls sys._getframe(0) to verify that the Frame wrapper works. The critical severity comes from the anti-analysis heuristic, and the snippet shows no evasive behavior.
-
return =likely benign Test helper calling sys._getframe(0) to exercise pytest's Frame wrapper.Reasoning
This is pytest's own test suite for its code-introspection helpers; sys._getframe is used deliberately to test Frame objects. Benign test code.
-
return =likely benign Test function returning sys._getframe(0) to build a Frame for testing.Reasoning
Same pattern in pytest's test suite testing frame introspection with varied signatures; no malicious behavior.
-
return =likely benign Test function returning its own frame for Frame API tests.Reasoning
Pytest test fixture exercising frame capture with *args; benign test scaffolding.
-
return =likely benign Test function returning its own frame, variant with keyword args.Reasoning
Pytest test code checking frame introspection with **kwargs; expected behavior for the library under test.
-
return =likely benign Test function returning its own frame, variant with *args and **kwargs.Reasoning
Pytest test covering frame introspection with mixed arguments; benign.
-
=likely benign Test executes a compiled code object to produce an exception for ExceptionInfo testing.Reasoning
Pytest's excinfo tests compile and exec a code object deliberately to generate a traceback for testing; not obfuscation.
-
=likely benign Test execs a compiled snippet to raise an error for traceback assertions.Reasoning
Same deliberate exec of a test code object in pytest's excinfo test suite.
-
nonlocal = . assert is not Nonelikely benign Test inspects the upper frame's code name to verify path creation.Reasoning
Test checking the calling function name via frame back-reference, a normal pattern in pytest tests.
-
= = .likely benign Exception-like class capturing caller frame to extract its source statement.Reasoning
Pytest source-inspection code capturing the caller frame to record a statement; legitimate library behavior.
-
= =likely benign Test compiles a small generated code snippet for source-lookup testing.Reasoning
Test compiles a fixed source string to check linecache and findsource behavior; benign.
-
: = , = assert is not Nonelikely benign Test evals a compiled code object to check source location lookup.Reasoning
Test evaluates a compiled code object in a dict namespace to verify findsource; benign test logic.
-
= = .likely benign Exception-like class capturing caller frame to extract its source statement.Reasoning
Duplicate of the pytest source-inspection frame capture pattern; legitimate.
-
= 99 return # fmt: onlikely benign Test helper compiling generated Python source to check line numbering.Reasoning
This is a pytest test helper that compiles a constructed source string with padding lines to test line-number handling. It is a test fixture for source-code utilities, not a payload.
-
likely benign Test fixture restoring the original sys trace function after a check.
Reasoning
Restoring the original trace function in a test conftest is a standard pattern to ensure tests do not leak a settrace hook; no malicious use is visible.
-
info
identifier-low-lengthtesting/example_scripts/dataclasses/test_compare_recursive_dataclasses.py:1:1 -
=likely benign Build script invoking PyInstaller via a shell command assembled from local arguments.Reasoning
This is a freeze-test script building a PyInstaller command from a fixed list of arguments. shell=True with a joined list is poor practice but the inputs are local constants, not attacker-controlled. Still, the pattern is a shell call worth noting in a test tool.
-
+=likely benign Test runner calling os.system on the frozen test executable.Reasoning
Runs a locally built test executable with a literal suffix in a freeze test runner. The command is a fixed test invocation with no external input.
-
= assert == 21 # 5*2 + 1 + 5*2 -
= assert == 21 # 5*2 + 1 + 5*2 -
-
-
-
-
-
= assert == ==likely benign Test helper evaluating test-supplied strings to verify repr behavior.Reasoning
Inside a test checking string and repr round-tripping of exception group representations, eval is applied to test-provided strings. This is a test of evaluation behavior, not a hidden payload.
-
= = : =likely benign Assertion-rewrite test helper compiling and executing rewritten test source.Reasoning
This is pytest's assertion-rewrite test harness, which compiles rewritten AST modules and execs them. The marshal and compile pattern is an artifact of testing the rewriter, not a multi-stage dropper.
-
= = : =likely benign Test harness compiling rewritten module source.Reasoning
compile of a rewritten module in the assertion-rewrite test harness is the expected operation under test. Input is locally generated test source.
-
=likely benign Test harness executing compiled test function in a namespace.Reasoning
exec of compiled test code in a fresh namespace is how the assertion-rewrite tests run their generated functions. No external or encoded input is involved.
-
= assert =likely benign Test helper reading caller frame to check reported line locations.Reasoning
Using inspect.currentframe to compute the caller line for location assertions is a common test technique in pytest's rewrite tests. The sys.exit/exec co-occurrence reflects test scaffolding, not anti-analysis.
-
= = =likely benign Test code compiling and executing rewritten source to check locations.Reasoning
Compile and exec of rewritten source with locations tracking is part of the assertion-rewrite location tests, operating on local test strings.
-
= = =likely benign Test code executing rewritten module for location checks.Reasoning
Executing the compiled rewritten module in the test's globals is expected for this test harness; the source is local test data.
-
= =likely benign Test code compiling source to compare original locations.Reasoning
Compile of a test-provided source string in the location-checking test, matching the surrounding pattern of the pytest rewrite test suite.
-
= =likely benign Test code executing source to record original locations.Reasoning
Executing compiled test source to capture original locations is standard in this pytest test module, with no external or encoded input.
-
= # Good header.likely benign Test code that compiles source bytes and marshals them to build a .pyc file for assertion-rewrite testing.Reasoning
This is a pytest test file exercising assertion rewriting. The compile call is on source_bytes produced from a test fixture, inside a test that builds a .pyc with a header via marshal. Compiling a non-literal is the expected behavior for testing pyc generation, not malicious execution.
-
""" >>> name = 'с' # not letter 'c' but instead Cyrillic 's'. 'anything' """ -
, , , , -
., ]likely benign Test fixture using a mixed Latin/Hebrew keyword argument to exercise non-ASCII mark names in pytest.Reasoning
The identifier mixes Latin and Hebrew letters, but this is a deliberate test of non-ASCII keyword handling in pytest mark expressions. The file is in the testing directory, the code carries a pylint disable comment for non-ascii-name, and the paired keyword uses the same Hebrew text. This is intentional test data, not obfuscation.
-
., ] -
, , , , -
, , , , -
, , , ,
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.
&&