https://github.com/pomponchik/flask_fixture
Start and stop the flask server for your tests
https://github.com/pomponchik/flask_fixture
fixtures flask pytest pytest-plugin server testing
Last synced: 7 months ago
JSON representation
Start and stop the flask server for your tests
- Host: GitHub
- URL: https://github.com/pomponchik/flask_fixture
- Owner: pomponchik
- License: mit
- Created: 2023-09-11T14:18:16.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-09T17:40:09.000Z (11 months ago)
- Last Synced: 2025-06-09T21:07:22.247Z (8 months ago)
- Topics: fixtures, flask, pytest, pytest-plugin, server, testing
- Language: Python
- Homepage:
- Size: 138 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://pepy.tech/project/flask_fixture)
[](https://pepy.tech/project/flask_fixture)
[](https://codecov.io/gh/pomponchik/flask_fixture)
[](https://hitsofcode.com/github/pomponchik/flask_fixture/view?branch=main)
[](https://github.com/pomponchik/flask_fixture/actions/workflows/tests_and_coverage.yml)
[](https://pypi.python.org/pypi/flask_fixture)
[](https://badge.fury.io/py/flask_fixture)
[](http://mypy-lang.org/)
[](https://github.com/astral-sh/ruff)
A simple plugin for [Pytest](https://docs.pytest.org/) containing a [fixture](https://docs.pytest.org/explanation/fixtures.html) that can start and stop the [Flask server](https://flask.palletsprojects.com/server/) to run related tests. You just have to define the [routes](https://flask.palletsprojects.com/quickstart/#routing).
Install it by the command:
```bash
pip install flask_fixture
```
Define some routes in your `conftest.py` file:
```python
from flask_fixture import endpoint
@endpoint('/')
def root():
return 'some text'
```
And use a URL of a server in your tests as a fixture `local_server_url`:
```python
import requests
def test_server(local_server_url):
assert requests.get(local_server_url).text == 'some text'
```
The example uses the [Requests](https://requests.readthedocs.io/en/latest/) library.