pytest-sherlock
Pytest plugin which help to find coupled tests.
Sometimes we have coupled tests which depend from ordering
For example:
- PASSES
tests/exmaple/test_all_read.py tests/exmaple/test_b_modify.py tests/exmaple/test_c_delete.py - FAILED
tests/exmaple/test_c_delete.py tests/exmaple/test_b_modify.py tests/exmaple/test_all_read.py
In this case pretty simple to detect coupled tests, but if we have >=1k tests which called before it will hard
Content:
Install
pip install pytest-sherlock
how to use:
pytest tests/exmaple/test_c_delete.py tests/exmaple/test_b_modify.py tests/exmaple/test_all_read.py --flaky-test="test_read_params" -vv
Plugin didn't run all tests, it try to find some possible guilty test and will run first
Try to find coupled tests in [3-4] steps
__________________________ Step [1 of 4]: __________________________
tests/exmaple/test_c_delete.py::test_delete_random_param PASSED [ 20%]
tests/exmaple/test_b_modify.py::test_modify_random_param PASSED [ 40%]
tests/exmaple/test_c_delete.py::test_deleted_passed PASSED [ 60%]
tests/exmaple/test_c_delete.py::test_do_not_delete PASSED [ 80%]
tests/exmaple/test_all_read.py::test_read_params COUPLED [100%]
__________________________ Step [2 of 4]: __________________________
tests/exmaple/test_c_delete.py::test_delete_random_param PASSED [ 33%]
tests/exmaple/test_b_modify.py::test_modify_random_param PASSED [ 66%]
tests/exmaple/test_all_read.py::test_read_params COUPLED [100%]
__________________________ Step [3 of 4]: __________________________
tests/exmaple/test_c_delete.py::test_delete_random_param PASSED [ 50%]
tests/exmaple/test_all_read.py::test_read_params PASSED [100%]
__________________________ Step [4 of 4]: __________________________
tests/exmaple/test_b_modify.py::test_modify_random_param PASSED [ 50%]
tests/exmaple/test_all_read.py::test_read_params COUPLED [100%]
=================== found coupled in 0.08 seconds ===================
Found coupled tests:
tests/exmaple/test_b_modify.py::test_modify_random_param
tests/exmaple/test_all_read.py::test_read_params
Common fixtures:
config
How to reproduce:
pytest -l -vv tests/exmaple/test_b_modify.py::test_modify_random_param tests/exmaple/test_all_read.py::test_read_params
__________________________ test_read_params __________________________
config = {'a': 1, 'b': 13, 'c': 3}, param = 'b'
def test_read_params(config, param):
> assert config.get(param) == 2
E AssertionError: assert 13 == 2
E + where 13 = <built-in method get of dict object at 0x10ef1ed70>('b')
E + where <built-in method get of dict object at 0x10ef1ed70> = {'a': 1, 'b': 13, 'c': 3}.get
tests/exmaple/test_all_read.py:8: AssertionError
=================== 9 passed, 3 coupled in 0.08 seconds ===================
TODO
I have a couple ideas, how to improve finder coupled tests:
- use AST for detect common peace of code (variables, functions, etc...)
- Also need to add tests for it =)
Metadata
Release files for pytest-sherlock 0.1.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest-sherlock-0.1.15.tar.gz | 7.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_sherlock-0.1.15-py2-none-any.whl | Python 2 | none | any | Details |
Total release size: 15.6 kB
Release files / pytest-sherlock-0.1.15.tar.gz
| Download URL | pytest-sherlock-0.1.15.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3248b2e9f713722cea760e377368f72feeb449affeeb1f8176f27ef86d6b04c0
|
|
BLAKE2b-256 checksum How to use checksums |
cd3a38ecfdaf1260e1054e745da37915a3da51e78aeb9929c6fe5aad96f3080b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/2.7.15
|
Release files / pytest_sherlock-0.1.15-py2-none-any.whl
| Download URL | pytest_sherlock-0.1.15-py2-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
bbfb431adc8c13979eb76e974b199f3eec81295d215800bc6973decd589dc952
|
|
BLAKE2b-256 checksum How to use checksums |
b38e92050b368d3c34ec794f372640f325ef6165a3a059f8cc0aacb91520f0de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/2.7.15
|