pytest-memray#
A pytest plugin for easy integration of memray
in your test suite. It can produce
reports like:
$ pytest --memray /w/demo
=================================== test session starts ====================================
platform linux -- Python 3.11.4, pytest-7.4.0, pluggy-1.2.0
rootdir: /w
plugins: memray-1.4.2.dev14+g7705a53.d20230822, flaky-3.7.0, xdist-3.3.1
collected 2 items
demo/test_ok.py .M [100%]
========================================= FAILURES =========================================
____________________________________ test_memory_exceed ____________________________________
Test was limited to 100.0KiB but allocated 117.2KiB
------------------------------------ memray-max-memory -------------------------------------
List of allocations:
- 117.2KiB allocated here:
<listcomp>:/w/demo/test_ok.py:17
...
====================================== MEMRAY REPORT =======================================
Allocation results for demo/test_ok.py::test_memory_exceed at the high watermark
📦 Total memory allocated: 117.2KiB
📏 Total allocations: 30
📊 Histogram of allocation sizes: |█|
🥇 Biggest allocating functions:
- <listcomp>:/w/demo/test_ok.py:17 -> 117.2KiB
Allocation results for demo/test_ok.py::test_track at the high watermark
📦 Total memory allocated: 39.1KiB
📏 Total allocations: 3
📊 Histogram of allocation sizes: |█|
🥇 Biggest allocating functions:
- test_track:/w/demo/test_ok.py:12 -> 39.1KiB
================================= short test summary info ==================================
MEMORY PROBLEMS demo/test_ok.py::test_memory_exceed
=============================== 1 failed, 1 passed in 0.02s ================================