pytest-race
https://github.com/idlesign/pytest-race
Description
Race conditions tester for pytest
Introduces start_race fixture to run race condition tests.
Requirements
Python 3.7+
pytest 2.9.0+
Usage
You can use start_race fixture in your tests as follows:
from time import sleep
ACCUMULATOR = 0 # This global var is race conditions prone.
def test_race(start_race):
from random import randint
def actual_test():
global ACCUMULATOR
increment = randint(1, 10000)
accumulator = ACCUMULATOR
sleep(1) # Simulate some lag.
ACCUMULATOR += increment
# By that moment ACCUMULATOR should have been updated
# by another thread. Let's try to prove it.
# Using simple `assert` as usual for pytest.
assert accumulator + increment == ACCUMULATOR
# Let's run `actual_test` in 2 threads.
start_race(threads_num=2, target=actual_test)
start_race accepts the following arguments:
threads_num - number of threads to run simultaneously.
target - actual test callable to run in threads.
Metadata
Release files for pytest-race 0.2.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-race-0.2.0.tar.gz | 5.4 kB | Without provenance | Details for pytest-race-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_race-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for pytest_race-0.2.0-py3-none-any.whl |
Total release size: 10.5 kB
Release files / pytest-race-0.2.0.tar.gz
| Download URL | pytest-race-0.2.0.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
92a43179ece42366ae2207bf4160bdb64781dc2ca425d1b37dc310c58ad0ade3
|
|
BLAKE2b-256 checksum How to use checksums |
2119aaec2ab5958304d74d8899e12e72987f17787f0c64c1b53873c7ff568089
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.8
|
Release files / pytest_race-0.2.0-py3-none-any.whl
| Download URL | pytest_race-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f2ae6cf1feece53619a76534a38863565b95f91436e78fb1bc7090234317eaf9
|
|
BLAKE2b-256 checksum How to use checksums |
04f2d30028f66885ae12ff210d35c93f827828b1c2d213d51d5f06b32ba3e8a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.8
|
Security for pytest-race 0.2.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.