MCPcopy
hub / github.com/pytest-dev/pytest / tracemalloc_message

Function tracemalloc_message

src/_pytest/tracemalloc.py:4–24  ·  src/_pytest/tracemalloc.py::tracemalloc_message
(source: object)

Source from the content-addressed store, hash-verified

2
3
4def tracemalloc_message(source: object) -> str:
5 if source is None:
6 return class="st">""
7
8 try:
9 import tracemalloc
10 except ImportError:
11 return class="st">""
12
13 tb = tracemalloc.get_object_traceback(source)
14 if tb is not None:
15 formatted_tb = class="st">"\n".join(tb.format())
16 class="cm"># Use a leading new line to better separate the (large) output
17 class="cm"># from the traceback to the previous warning text.
18 return fclass="st">"\nObject allocated at:\n{formatted_tb}"
19 class="cm"># No need for a leading new line.
20 url = class="st">"https://docs.pytest.org/en/stable/how-to/capture-warnings.htmlclass="cm">#resource-warnings"
21 return (
22 class="st">"Enable tracemalloc to get traceback where the object was allocated.\n"
23 fclass="st">"See {url} for more info."
24 )

Callers 3

unraisable_hookFunction · 0.90
thread_exception_hookFunction · 0.90
warning_record_to_strFunction · 0.90

Calls 2

joinMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected