{"id":27300,"library":"pytest-loop","title":"pytest-loop","description":"A pytest plugin that allows running tests in a loop until they fail (or pass), useful for detecting flaky tests. Current version 1.0.13, compatible with Python >=3.7. Maintenance mode with infrequent releases.","status":"active","version":"1.0.13","language":"python","source_language":"en","source_url":"https://github.com/anogowski/pytest-loop","tags":["pytest","plugin","loop","flaky","testing"],"install":[{"cmd":"pip install pytest-loop","lang":"bash","label":"Latest release"}],"dependencies":[{"reason":"Core dependency: pytest plugin","package":"pytest","optional":false}],"imports":[{"note":"The marker is automatically registered by the plugin. No explicit import required.","symbol":"pytest.mark.loop","correct":"pytest.mark.loop decorator (no import needed; automatically registered as a marker)"}],"quickstart":{"code":"# test_example.py\nimport pytest\n\ndef test_flaky():\n    import random\n    assert random.choice([True, False])\n\n# Run with: pytest --loop 10 test_example.py\n# Or use @pytest.mark.loop(10) on a single test\n","lang":"python","description":"Basic usage: run a test in a loop until it fails or reaches the given count."},"warnings":[{"fix":"Use pytest.mark.loop(N) for specific tests, or --loop N for global loop count.","message":"The --loop option applies to all tests in the session. Use @pytest.mark.loop to control per-test loop count.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure tests are idempotent or use fixtures that clean up after each iteration.","message":"Running in loop mode can cause side effects like repeated database writes or file modifications. Use with caution on tests with side effects.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Do not import pytest.mark.loop. Just use @pytest.mark.loop(N) in test files; the marker is registered automatically when pytest-loop is installed.","cause":"Trying to import pytest.mark.loop after patching pytest.mark incorrectly.","error":"AttributeError: module 'pytest' has no attribute 'mark'"},{"fix":"Add --loop N to pytest command or decorate test with @pytest.mark.loop(N).","cause":"Forgetting to include @pytest.mark.loop or --loop option.","error":"Loop count not respected, test runs only once"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}