Detects tests leaking threads
Installation
You can install “pytest-threadleak” via pip from PyPI:
$ pip install pytest-threadleak
Usage
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+
Contributing
Running the tests:
$ tox
License
Distributed under the terms of the MIT license, “pytest-threadleak” is free and open source software
Credits
This Pytest plugin was generated with Cookiecutter along with @hackebrot’s Cookiecutter-pytest-plugin template.
Metadata
Release files for pytest-threadleak 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytest-threadleak-0.5.0.tar.gz | 4.3 kB | Without provenance | Details for pytest-threadleak-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_threadleak-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for pytest_threadleak-0.5.0-py3-none-any.whl |
Total release size: 8.0 kB
Release files / pytest-threadleak-0.5.0.tar.gz
| Download URL | pytest-threadleak-0.5.0.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
57a39b1c5c2263d8b0cc17bb2d295e19d7a6efa9122c89550f999e23711b6aa0
|
|
BLAKE2b-256 checksum How to use checksums |
ac198cf45fd6d6a450a13a571ed77d76965c83bfc6f49379ff79b115d838d0d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / pytest_threadleak-0.5.0-py3-none-any.whl
| Download URL | pytest_threadleak-0.5.0-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f3e1b41d5b1e04443703496a575acad61c7d3c3f7024e973e901ca0945893f24
|
|
BLAKE2b-256 checksum How to use checksums |
c081440cac8f786c998be695d76593b4b93137e5dc5824bec1425ba52672512f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Security for pytest-threadleak 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.