Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

A pytest plugin to trace resource leaks.

Project description

pytest-leaks - A pytest plugin to trace resource leaks

.. image::
:alt: See Package Info on PyPI

.. image::
:alt: See Build Status on Travis CI

.. image::
:alt: See Build Status on AppVeyor

A pytest plugin to trace resource leaks.


To add a leaks test to your py.test session, add the ``-R`` option on the command line::

$ py.test -v -R :
============================= test session starts =============================
platform darwin -- Python 3.5.2+, pytest-3.0.5.dev0, py-1.4.31, pluggy-0.4.0 --
cachedir: .cache
rootdir: .../abalkin/pytest-leaks, inifile:
plugins: leaks-0.2.0, cov-2.4.0, pyq-1.1
collected 3 items LEAKED FAILED PASSED

================================ leaks summary ================================ Leaks([('refs', [2, 2, 2, 2])])
================================== FAILURES ===================================
_____________________________ test_broken_fauset ______________________________

def test_broken_fauset():
> assert 0
E assert 0 AssertionError
================ 1 failed, 1 passed, 1 leaked in 0.46 seconds =================

The test file used above contains the following code::

$ cat
drops = []
def test_leaky_fauset():

def test_broken_fauset():
assert 0

def test_mended_fauset():
assert 1


* Detects memory leaks by running py.test tests repeatedly and comparing total reference
counts between the runs.


* py.test version >= TBD;
* A debug build of Python 3.5.


You can install "pytest-leaks" via `pip`_ from `PyPI`_::

$ pip install pytest-leaks



Contributions are very welcome. Tests can be run with `tox`_, please ensure
the coverage at least stays the same before you submit a pull request.


Distributed under the terms of the `MIT`_ license, "pytest-leaks" is free and open source software.


If you encounter any problems, please `file an issue`_ along with a detailed description.


This `Pytest`_ plugin was initially generated with `Cookiecutter`_ along with `@hackebrot`_'s
`Cookiecutter-pytest-plugin`_ template.

.. _`Cookiecutter`:
.. _`@hackebrot`:
.. _`MIT`:
.. _`BSD-3`:
.. _`GNU GPL v3.0`:
.. _`Apache Software License 2.0`:
.. _`cookiecutter-pytest-plugin`:
.. _`file an issue`:
.. _`pytest`:
.. _`tox`:
.. _`pip`:
.. _`PyPI`:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pytest_leaks-0.2.1-py3-none-any.whl (8.3 kB) Copy SHA256 hash SHA256 Wheel py3

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page