pytest-memray#
A pytest plugin for easy integration of memray
in your test suite.
It can produce reports like:
$ python3 -m pytest tests --memray
=============================== test session starts ================================
platform linux -- Python 3.8.10, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /mypackage, configfile: pytest.ini
plugins: cov-2.12.0, memray-0.1.0
collected 21 items
tests/test_package.py ..................... [100%]
================================= MEMRAY REPORT ==================================
Allocations results for tests/test_package.py::some_test_that_allocates
📦 Total memory allocated: 24.4MiB
📏 Total allocations: 33929
📊 Histogram of allocation sizes: |▂ █ |
🥇 Biggest allocating functions:
- parse:/opt/bb/lib/python3.8/ast.py:47 -> 3.0MiB
- parse:/opt/bb/lib/python3.8/ast.py:47 -> 2.3MiB
- _visit:/opt/bb/lib/python3.8/site-packages/astroid/transforms.py:62 -> 576.0KiB
- parse:/opt/bb/lib/python3.8/ast.py:47 -> 517.6KiB
- __init__:/opt/bb/lib/python3.8/site-packages/astroid/node_classes.py:1353 -> 512.0KiB