Code Monkey home page Code Monkey logo

pytest-leaks's Introduction

pytest-leaks - A pytest plugin to trace resource leaks

See Package Info on PyPI See Build Status on Travis CI See Build Status on AppVeyor

A pytest plugin to trace resource leaks.

Usage

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

$ py.test -v -R : test_fauset.py
============================= 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

test_fauset.py::test_leaky_fauset LEAKED
test_fauset.py::test_broken_fauset FAILED
test_fauset.py::test_mended_fauset PASSED

================================ leaks summary ================================
test_fauset.py::test_leaky_fauset: Leaks([('refs', [2, 2, 2, 2])])
================================== FAILURES ===================================
_____________________________ test_broken_fauset ______________________________

    def test_broken_fauset():
>       assert 0
E       assert 0

test_fauset.py:6: AssertionError
================ 1 failed, 1 passed, 1 leaked in 0.46 seconds =================

The test file used above contains the following code:

$ cat test_fauset.py
drops = []
def test_leaky_fauset():
    drops.append({})

def test_broken_fauset():
    assert 0

def test_mended_fauset():
    assert 1

Features

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

Requirements

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

Installation

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

$ pip install pytest-leaks

Contributing

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.

License

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

Issues

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

Acknowledgements

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

pytest-leaks's People

Contributors

abalkin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.