{"id":33182879,"url":"https://github.com/felipecrp/pytest-pyspec","last_synced_at":"2026-02-20T03:07:52.456Z","repository":{"id":140529478,"uuid":"605758987","full_name":"felipecrp/pytest-pyspec","owner":"felipecrp","description":"A plugin that transforms the pytest output into a result similar to the RSpec.","archived":false,"fork":false,"pushed_at":"2025-11-18T02:56:11.000Z","size":86,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-18T03:03:33.557Z","etag":null,"topics":["pytest","python","testing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/felipecrp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-02-23T20:55:44.000Z","updated_at":"2025-11-18T02:56:15.000Z","dependencies_parsed_at":"2024-01-02T15:35:20.451Z","dependency_job_id":null,"html_url":"https://github.com/felipecrp/pytest-pyspec","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/felipecrp/pytest-pyspec","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipecrp%2Fpytest-pyspec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipecrp%2Fpytest-pyspec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipecrp%2Fpytest-pyspec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipecrp%2Fpytest-pyspec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felipecrp","download_url":"https://codeload.github.com/felipecrp/pytest-pyspec/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felipecrp%2Fpytest-pyspec/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29639814,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T22:32:43.237Z","status":"online","status_checked_at":"2026-02-20T02:00:07.535Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pytest","python","testing"],"created_at":"2025-11-16T04:00:32.219Z","updated_at":"2026-02-20T03:07:52.444Z","avatar_url":"https://github.com/felipecrp.png","language":"Python","funding_links":[],"categories":["Behavior-driven Development"],"sub_categories":[],"readme":"[![](https://github.com/felipecrp/pytest-pyspec/actions/workflows/pytest.yml/badge.svg)](https://github.com/felipecrp/pytest-pyspec/actions/workflows/pytest.yml)\n\n# pytest-pyspec\n\nThe **pytest-pyspec** plugin transforms pytest output into a beautiful, readable format similar to RSpec. It provides semantic meaning to your tests by organizing them into descriptive hierarchies, using the prefixes `Describe`/`Test`, `With`/`Without`/`When`, and `test_`/`it_`, while allowing docstrings and decorators to override the descriptions.\n\n## Features\n\n- **Semantic Output**: Transform pytest's default output into readable, hierarchical descriptions\n- **Multiple Prefixes**: Support for `describe/test` (objects), `with/without/when` (contexts), and `it/test` (tests)\n- **Docstring Support**: Override test descriptions using docstrings\n- **Consolidated Output**: Smart grouping that avoids repeating parent headers\n- **Natural Language**: Automatic lowercase formatting of common words (the, is, are, etc.)\n- **Decorator Support**: Override descriptions right next to your classes and tests\n\n## Quick Start\n\n### Installation\n\n```bash\npip install pytest pytest-pyspec\n```\n\n### Running\n\n```bash\npytest --pyspec\n```\n\n## Examples\n\n### Car Scenario\n\nA minimal car example with properties and behaviors:\n\n```python\nclass DescribeCar:\n    def test_has_engine(self):\n        assert True\n\n    class WithFullTank:\n        def test_drive_long_distance(self):\n            assert True\n\n    class WithoutFuel:\n        def test_cannot_start_engine(self):\n            assert True\n\n    class WhenTheEngineIsRunning:\n        def test_consumes_fuel(self):\n            assert True\n```\n\nWith **pytest-pyspec**, this produces:\n\n```\na Car\n  ✓ has engine\n\n  with Full Tank\n    ✓ drive long distance\n\n  without Fuel\n    ✓ cannot start engine\n\n  when the Engine is Running\n    ✓ consumes fuel\n```\n\n### Available Prefixes\n\n**pytest-pyspec** supports three types of prefixes to create semantic test hierarchies:\n\n#### 1. Object Classes (use `describe` or `test`)\n\nDefine what you're testing:\n\n```python\nclass DescribeCar:  # or class TestCar:\n    def test_has_four_wheels(self):\n        assert True\n```\n\nOutput:\n```\na Car\n  ✓ has four wheels\n```\n\n#### 2. Context Classes (use `with`, `without`, or `when`)\n\nDefine the context or state:\n\n```python\nclass DescribeCar:\n    class WithFullTank:\n        def test_can_drive_long_distances(self):\n            assert True\n\n    class WithoutFuel:\n        def test_cannot_start_engine(self):\n            assert True\n\n    class WhenTheEngineIsRunning:\n        def test_consumes_fuel(self):\n            assert True\n```\n\nOutput:\n```\na Car\n  with Full Tank\n    ✓ can drive long distances\n\n  without Fuel\n    ✓ cannot start engine\n\n  when the Engine is Running\n    ✓ consumes fuel\n```\n\n#### 3. Test Functions (use `it_` or `test_`)\n\nDefine the expected behavior:\n\n```python\nclass DescribeCar:\n    def it_has_four_wheels(self):\n        assert True\n\n    def test_has_engine(self):\n        assert True\n```\n\nOutput:\n```\na Car\n  ✓ has four wheels\n  ✓ has engine\n```\n\n### Using Docstrings\n\nOverride automatic naming with custom descriptions:\n\n```python\nclass TestCar:\n    \"\"\"sports car\"\"\"\n    \n    def test_top_speed(self):\n        \"\"\"reaches 200 mph\"\"\"\n        assert True\n\n    class WhenTheNitroIsActivated:\n        \"\"\"when nitro boost is activated\"\"\"\n        \n        def test_acceleration(self):\n            \"\"\"accelerates rapidly\"\"\"\n            assert True\n```\n\nOutput:\n```\na sports car\n  ✓ reaches 200 mph\n\n  when nitro boost is activated\n    ✓ accelerates rapidly\n```\n\n### Using Decorators\n\nPrefer decorators over docstrings? Import the helpers directly from `pytest_pyspec`:\n\n```python\nimport pytest_pyspec as spec\n\n@spec.describe(\"Car\")\nclass DescribeCar:\n    @spec.it(\"reaches 200 mph\")\n    def test_top_speed(self):\n        assert True\n\n    @spec.when(\"nitro boost is activated\")\n    class WhenTheNitroIsActivated:\n        @spec.it(\"accelerates rapidly\")\n        def test_acceleration(self):\n            assert True\n```\n\nOutput:\n```\na Car\n  ✓ reaches 200 mph\n\n  when nitro boost is activated\n    ✓ accelerates rapidly\n```\n\nYou can also import individual helpers (`describe`, `with_`, `without`, `when`,\n`it`) directly from `pytest_pyspec` if you prefer `from ... import ...` style.\n`with` is still exposed as `with_` because the plain name is reserved.\n\nDecorators always win when both a docstring and a decorator are present, so you\ncan keep docstrings for documentation/IDE help while letting decorators drive\nruntime output.\n\n## Configuration\n\nThe plugin is automatically enabled when you use the `--pyspec` flag. No additional configuration is required.\n\nFor more information, see the [documentation](https://github.com/felipecrp/pytest-pyspec/blob/main/doc/README.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelipecrp%2Fpytest-pyspec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelipecrp%2Fpytest-pyspec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelipecrp%2Fpytest-pyspec/lists"}