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.12.3, pytest-8.3.3, pluggy-1.5.0
rootdir: /home/docs/checkouts/readthedocs.org/user_builds/pytest-memray/checkouts/latest
configfile: pyproject.toml
plugins: memray-1.7.1.dev3+g0597519
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:

====================================== MEMRAY REPORT =======================================
Allocation results for docs/demo/test_ok.py::test_memory_exceed at the high watermark

	 πŸ“¦ Total memory allocated: 117.2KiB
	 πŸ“ Total allocations: 1
	 πŸ“Š Histogram of allocation sizes: |β–ˆ|
	 πŸ₯‡ Biggest allocating functions:


Allocation results for docs/demo/test_ok.py::test_track at the high watermark

	 πŸ“¦ Total memory allocated: 39.1KiB
	 πŸ“ Total allocations: 1
	 πŸ“Š Histogram of allocation sizes: |β–ˆ|
	 πŸ₯‡ Biggest allocating functions:


================================= short test summary info ==================================
MEMORY PROBLEMS demo/test_ok.py::test_memory_exceed
=============================== 1 failed, 1 passed in 0.04s ================================