Package: pytest-sherlock
pytest-sherlockPytest plugin which help to find coupled tests.Sometimes we have coupled tests which depend from orderingFor example:PASSEStests/exmaple/test_all_read.py tests/exmaple/test_b_modify.py tests/exmaple/test_c_delete.pyFAILEDtests/exmaple/test_c_delete.py tests/exmaple/test_b_modify.py tests/exmaple/test_all_read.pyIn this case pretty simple to detect coupled tests, but if we have >=1k tests which called before it will hardContent:installhow to usewaiting in the futureInstallpipinstallpytest-sherlockhow to use:pytesttests/exmaple/test_c_delete.pytests/exmaple/test_b_modify.pytests/exmaple/test_all_read.py--flaky-test="test_read_params"-vvPlugin didn't run all tests, it try to find some possible guilty test and will run firstTrytofindcoupledtestsin[3-4]steps
__________________________Step[1of4]:__________________________

tests/exmaple/test_c_delete.py::test_delete_random_paramPASSED[20%]tests/exmaple/test_b_modify.py::test_modify_random_paramPASSED[40%]tests/exmaple/test_c_delete.py::test_deleted_passedPASSED[60%]tests/exmaple/test_c_delete.py::test_do_not_deletePASSED[80%]tests/exmaple/test_all_read.py::test_read_paramsFAILED[100%]__________________________Step[2of4]:__________________________

tests/exmaple/test_c_delete.py::test_delete_random_paramPASSED[33%]tests/exmaple/test_b_modify.py::test_modify_random_paramPASSED[66%]tests/exmaple/test_all_read.py::test_read_paramsFAILED[100%]__________________________Step[3of4]:__________________________

tests/exmaple/test_c_delete.py::test_delete_random_paramPASSED[50%]tests/exmaple/test_all_read.py::test_read_paramsPASSED[100%]__________________________Step[4of4]:__________________________

tests/exmaple/test_b_modify.py::test_modify_random_paramPASSED[50%]tests/exmaple/test_all_read.py::test_read_paramsFAILED[100%]==============================FAILURES==============================__________________________test_read_params__________________________

Foundcoupledtests:
tests/exmaple/test_b_modify.py::test_modify_random_param
tests/exmaple/test_all_read.py::test_read_params

Commonfixtures:
config

Howtoreproduce:
pytest-l-vvtests/exmaple/test_b_modify.py::test_modify_random_paramtests/exmaple/test_all_read.py::test_read_params


AssertionError:assert13==2+where13=<built-inmethodgetofdictobjectat0x102664280>('b')+where<built-inmethodgetofdictobjectat0x102664280>={'a':1,'b':13,'c':3}.get

tests/exmaple/test_all_read.py:8:AssertionError===================1failed,9passedin0.08seconds===================The plugin also supports--lf(last failed) option to rerun found coupled tests.
It allows us to make sure that coupled tests are true.pytesttests/exmaple/test_c_delete.pytests/exmaple/test_b_modify.pytests/exmaple/test_all_read.py--lf===========================================================================testsessionstarts============================================================================platformdarwin--Python3.7.10,pytest-3.5.1,py-1.7.0,pluggy-0.6.0
collected10items/8deselected
run-last-failure:rerunprevious2failures

tests/exmaple/test_b_modify.py.[50%]tests/exmaple/test_all_read.pyF[100%]=================================================================================FAILURES=================================================================================_____________________________________________________________________________test_read_params_____________________________________________________________________________config={'a':1,'b':13,'c':3},param='b'deftest_read_params(config,param):
>assertconfig.get(param)==2EAssertionError:assert13==2E+where13=<built-inmethodgetofdictobjectat0x10c964cd0>('b')E+where<built-inmethodgetofdictobjectat0x10c964cd0>={'a':1,'b':13,'c':3}.get

tests/exmaple/test_all_read.py:6:AssertionError=============================================================1failed,1passed,8deselectedin0.05seconds=============================================================TODOI have a couple ideas, how to improve finder coupled tests:useASTfor detect common peace of code(variables, functions, etc...)