https://github.com/jacebrowning/pytest-expecter
Better testing with expecter and pytest.
https://github.com/jacebrowning/pytest-expecter
pytest python testing
Last synced: 10 months ago
JSON representation
Better testing with expecter and pytest.
- Host: GitHub
- URL: https://github.com/jacebrowning/pytest-expecter
- Owner: jacebrowning
- License: other
- Created: 2019-12-14T01:46:58.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2025-03-06T05:10:02.000Z (over 1 year ago)
- Last Synced: 2025-04-14T01:08:47.784Z (about 1 year ago)
- Topics: pytest, python, testing
- Language: Python
- Homepage: https://pytest-expecter.readthedocs.io
- Size: 679 KB
- Stars: 8
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Overview
A `pytest` plugin based on [garybernhardt/expecter](https://github.com/garybernhardt/expecter) to write expressive tests.
[](https://github.com/jacebrowning/pytest-expecter/actions/workflows/main.yml)
[](https://coveralls.io/r/jacebrowning/pytest-expecter)
[](https://pypi.org/project/pytest-expecter)
[](https://pypi.org/project/pytest-expecter)
[](https://pypistats.org/packages/pytest-expecter)
## Quick Start
With this plugin you can write tests (optionally using [pytest-describe](https://github.com/pytest-dev/pytest-describe)) like this:
```python
def describe_foobar():
def it_can_pass(expect):
expect(2 + 3) == 5
def it_can_fail(expect):
expect(2 + 3) == 6
```
and get output like this:
```python
============================= FAILURES =============================
___________________ describe_foobar.it_can_fail ____________________
def it_can_fail(expect):
> expect(2 + 3) == 6
E AssertionError: Expected 6 but got 5
test_foobar.py:7: AssertionError
================ 1 failed, 1 passed in 2.67 seconds ================
```
## Installation
Install it directly into an activated virtual environment:
```
$ pip install pytest-expecter
```
or add it to your [Poetry](https://python-poetry.org/docs/) project:
```
$ poetry add pytest-expecter
```