{"id":10152,"library":"pytest-spec","title":"pytest-spec: Specification-style Test Output","description":"pytest-spec is a pytest plugin that transforms the standard test execution output into a clear, human-readable specification format, similar to RSpec or Mocha. It uses test names and docstrings to generate descriptive sentences about test behavior. The current version is 6.0.0, and it follows a release cadence tied to pytest and Python major version updates.","status":"active","version":"6.0.0","language":"en","source_language":"en","source_url":"https://github.com/pchomik/pytest-spec","tags":["pytest","testing","spec","reporting","plugin"],"install":[{"cmd":"pip install pytest-spec","lang":"bash","label":"Install pytest-spec"}],"dependencies":[{"reason":"Required as it is a pytest plugin. Version 6.0.0+ is needed.","package":"pytest","optional":false}],"imports":[],"quickstart":{"code":"# test_example.py\nimport pytest\n\ndef test_feature_login_successful():\n    \"\"\"When valid credentials are provided, it should allow a user to log in successfully.\"\"\"\n    assert True\n\ndef test_feature_login_failed():\n    \"\"\"When invalid credentials are provided, it should deny access and show an error.\"\"\"\n    assert False\n\n@pytest.mark.parametrize(\"input, expected\", [(\"hello\", \"HELLO\"), (\"world\", \"WORLD\")])\ndef test_string_uppercase_conversion(input, expected):\n    \"\"\"It should correctly convert a given string to uppercase.\"\"\"\n    assert input.upper() == expected\n\n# To run these tests with pytest-spec, simply navigate to the directory\n# containing `test_example.py` in your terminal and run:\n# pytest","lang":"python","description":"Create a test file (e.g., `test_example.py`) and simply run `pytest` from your terminal after installation. pytest-spec automatically modifies the output."},"warnings":[{"fix":"Upgrade your Python environment to 3.10 or newer. For example: `pyenv install 3.10.12 && pyenv local 3.10.12`.","message":"Version 6.0.0 of pytest-spec drops support for Python 3.9. Users on Python 3.9 or older will experience compatibility issues.","severity":"breaking","affected_versions":"6.0.0"},{"fix":"Upgrade pytest to version 6.0.0 or newer. For example: `pip install 'pytest>=6.0.0,<10.0.0'`.","message":"Version 6.0.0 of pytest-spec drops support for pytest 4.x.x and 5.x.x. Running with these older pytest versions will lead to errors or incorrect behavior.","severity":"breaking","affected_versions":"6.0.0"},{"fix":"Add a clear, concise docstring to each test function or method explaining its purpose. Example: `def test_something(): \"\"\"It should do X when Y.\"\"\"`.","message":"For the most descriptive output, leverage docstrings in your test functions and methods. pytest-spec uses these to generate more readable specification descriptions.","severity":"gotcha","affected_versions":"all"},{"fix":"Run pytest with `pytest -p no:spec` to disable the plugin for that specific run. You can also add `addopts = -p no:spec` to your `pytest.ini` to disable it project-wide.","message":"If you need to temporarily disable pytest-spec or are experiencing conflicts with other plugins, you can disable it directly from the command line.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Run `pip install pytest-spec` to install the plugin.","cause":"The `pytest-spec` package has not been installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'pytest_spec'"},{"fix":"Ensure `pytest-spec` is installed. Check your `pytest.ini` for `addopts = -p no:spec`. You can run `pytest --trace-config` to see which plugins are loaded. If conflicts exist, try disabling other plugins, e.g., `pytest -p no:another_plugin`.","cause":"The `pytest-spec` plugin is either not active, has been explicitly disabled, or is being overridden by another pytest plugin.","error":"No 'spec' output, just standard pytest dots or progress."},{"fix":"Upgrade your pytest installation: `pip install 'pytest>=6.0.0,<10.0.0'`.","cause":"You are using an older version of pytest (pre-6.0.0) which is no longer supported by pytest-spec 6.0.0.","error":"You need to install pytest>=6.0.0 to use this plugin with current Python version."}]}