pytest-memray API¶
Types¶
- class pytest_memray.LeakedObjectsFilterFunction¶
Bases:
ProtocolA callable that can decide whether it’s OK for some object to be leaked.
This can be used with the
limit_leaked_objectsmarker to suppress leak reports for objects that are known to leak. For instance, you might know that objects of a certain type are cached by the code you’re invoking, and so you might want to ignore all reports of leaked objects of that type.You can provide any callable with the following signature as the
filter_fnkeyword argument for thelimit_leaked_objectsmarker:- __call__(obj: object) bool¶
Return whether a leak of this object should be reported.
Return
Trueif you want the leak to be reported (causing the test to fail), orFalseif you want it to be suppressed.
- class pytest_memray.LeaksFilterFunction¶
Bases:
ProtocolA callable that can decide whether to ignore some memory leaks.
This can be used with the
limit_leaksmarker to suppress leak reports from locations that are known to leak. For instance, you might know that objects of a certain type are cached by the code you’re invoking, and so you might want to ignore all reports of leaked memory allocated below that type’s constructor.You can provide any callable with the following signature as the
filter_fnkeyword argument for thelimit_leaksmarker:
- class pytest_memray.Stack¶
The call stack that led to some memory allocation.
You can inspect the frames which make up the call stack.
- frames: Tuple[StackFrame, ...]¶
The frames that make up the call stack, most recent first.
- class pytest_memray.StackFrame¶
One frame of a call stack.
Each frame has attributes to tell you what code was executing.
- filename: str¶
The source file being executed, or
"???"if unknown.
- function: str¶
The function being executed, or
"???"if unknown.
- lineno: int¶
The line number of the executing line, or
0if unknown.