
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
.. SPDX-FileCopyrightText: Nir Soffer nirsof@gmail.com .. .. SPDX-License-Identifier: MIT
.. image:: https://img.shields.io/pypi/v/pytest-threadleak.svg :target: https://pypi.python.org/pypi/pytest-threadleak :alt: Current version .. image:: https://img.shields.io/pypi/pyversions/pytest-threadleak :target: https://pypi.python.org/pypi/pytest-threadleak :alt: Supports Python 2.7, 3.10, 3.9, 3.8, 3.7, 3.7 .. image:: https://img.shields.io/pypi/dm/pytest-threadleak :target: https://pypi.python.org/pypi/pytest-threadleak :alt: Downloads per month .. image:: https://github.com/nirs/pytest-threadleak/actions/workflows/ci.yml/badge.svg :target: https://github.com/nirs/pytest-threadleak/actions/workflows/ci.yml :alt: Tests status .. image:: https://img.shields.io/pypi/l/pytest-threadleak :target: https://pypi.python.org/pypi/pytest-threadleak :alt: MIT license
You can install "pytest-threadleak" via pip
_ from PyPI
_::
$ pip install pytest-threadleak
The threadleak pytest plugin will fail leaking threads. This can be an issue in the test, or in the tested code.
Here is an example leaking test::
$ cat leak_test.py
import threading
import time
def test_leak():
threading.Thread(target=time.sleep, args=(1,)).start()
Here is an example run with thread leak plugin enabled::
$ pytest --threadleak leak_test.py
...
leak_test.py::test_leak FAILED
...
> ???
E Failed: Test leaked [<Thread(Thread-1, started 139762716391168)>]
If you want to enable thread leak by default, you can enable it in your pytest.ini or tox.ini::
[pytest]
threadleak = True
If you want to enable thread leak on a per test/module basis, you can
use the threadleak
pytest marker:
To enable it for a single test::
@pytest.mark.threadleak
def test_leak():
...
To disable it for a single test::
@pytest.mark.threadleak(enabled=False)
def test_leak():
...
For an entire test module::
import pytest
pytestmark = pytest.mark.threadleak(enabled=False)
If you want to exclude some threads from the leak check, you can specify a regex to match excluded thread names::
[pytest]
threadleak = True
threadleak_exclude = pool/\d+
Running the tests::
$ tox
Distributed under the terms of the MIT
_ license, "pytest-threadleak" is free
and open source software
This Pytest
_ plugin was generated with Cookiecutter
_ along with
@hackebrot
's Cookiecutter-pytest-plugin
template.
.. _Cookiecutter
: https://github.com/audreyr/cookiecutter
.. _@hackebrot
: https://github.com/hackebrot
.. _MIT
: http://opensource.org/licenses/MIT
.. _cookiecutter-pytest-plugin
: https://github.com/pytest-dev/cookiecutter-pytest-plugin
.. _pytest
: https://github.com/pytest-dev/pytest
.. _tox
: https://tox.readthedocs.io/en/latest/
.. _pip
: https://pypi.python.org/pypi/pip/
.. _PyPI
: https://pypi.python.org/pypi
FAQs
Detects thread leaks
We found that pytest-threadleak demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.