{"id":27305,"library":"pytest-reverse","title":"pytest-reverse","description":"A pytest plugin that reverses the order of test execution. Useful for detecting tests that accidentally depend on order or for randomization. Current version 1.9.0, compatible with Python >=3.9.","status":"active","version":"1.9.0","language":"python","source_language":"en","source_url":"https://github.com/adamchainz/pytest-reverse","tags":["pytest","plugin","testing","reverse-order"],"install":[{"cmd":"pip install pytest-reverse","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required plugin host. Must be installed.","package":"pytest","optional":false}],"imports":[{"note":"No direct import needed. Use the --reverse CLI flag or @pytest.mark.reverse() mark.","wrong":"","symbol":"reverse","correct":"pytest.mark.reverse"}],"quickstart":{"code":"# Run all tests in reverse order\npytest --reverse\n\n# Reverse a single test with marker\nimport pytest\n\n@pytest.mark.reverse()\ndef test_one():\n    assert True\n\ndef test_two():\n    assert True","lang":"python","description":"Use --reverse flag to reverse entire test session, or @pytest.mark.reverse() marker to reverse only specific tests."},"warnings":[{"fix":"To reverse test file order, use pytest --reverse --co (with pytest-order plugin) or sort test files manually.","message":"The --reverse flag reverses the order of tests within each scope (module, class, function). It does NOT reverse the order of test files unless combined with other plugins.","severity":"gotcha","affected_versions":"all"},{"fix":"Apply marker to each test function you want reversed, or use --reverse for global reversal.","message":"Using @pytest.mark.reverse() at the class level reverses tests within that class, but does not reverse tests outside the class.","severity":"gotcha","affected_versions":"all"},{"fix":"Use @pytest.mark.reverse() with parentheses.","message":"The pytest.mark.reverse marker without parentheses (e.g., @pytest.mark.reverse) is deprecated since version 1.7.0 and will be removed in a future release.","severity":"deprecated","affected_versions":">=1.7.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Add 'import pytest' at the top of your test file.","cause":"Forgetting to import pytest before using the marker.","error":"AttributeError: module 'pytest' has no attribute 'mark'"},{"fix":"Install with 'pip install pytest-reverse'.","cause":"pytest-reverse is not installed.","error":"Unknown pytest.mark.reverse - did you mean 'pytest.mark.skip'"},{"fix":"Install with 'pip install pytest-reverse' and ensure you're running pytest in the correct environment.","cause":"pytest-reverse is not installed or not registered as a plugin.","error":"WARNING: usage: pytest [options] [file_or_dir] error: unrecognized arguments: --reverse"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}