A set of py.test fixtures to test Flask extensions and applications.
Features
Plugin provides some fixtures to simplify app testing:
client - an instance of app.test_client,
client_class - client fixture for class-based tests,
config - you application config,
accept_json, accept_jsonp, accept_any - accept headers suitable to use as parameters in client.
To pass options to your application use the pytest.mark.app marker:
@pytest.mark.app(debug=False)
def test_app(app):
assert not app.debug, 'Ensure the app not in debug mode'
During tests execution the application has pushed context, e.g. url_for, session and other context bound objects are available without context managers:
def test_app(client):
assert client.get(url_for('myview')).status_code == 200
Response object has a json property to test a view that returns a JSON response:
@api.route('/ping')
def ping():
return jsonify(ping='pong')
def test_api_ping(client):
res = client.get(url_for('api.ping'))
assert res.json == {'ping': 'pong'}
Quick Start
To start using a plugin define you application fixture in conftest.py:
from myapp import create_app
@pytest.fixture
def app():
app = create_app()
return app
And run your test suite:
$ pip install pytest-flask
$ py.test
Contributing
Don’t hesitate to create a GitHub issue for any bug or suggestion.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest-flask-0.4.0.tar.gz.
File metadata
- Download URL: pytest-flask-0.4.0.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72dce0e4ad99b8d8a062833b8a963f81bb17a1f814acac7e59310644858dc064
|
|
| MD5 |
dade570bffef849f8fd27a4aacfff81b
|
|
| BLAKE2b-256 |
8e9c87d7b6ec33ca0cb3b604324e89a53094e06f50a35259f0bba189e7cd87f9
|
File details
Details for the file pytest_flask-0.4.0-py2.py3-none-any.whl.
File metadata
- Download URL: pytest_flask-0.4.0-py2.py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
450ffe48694a0cfb83f6f9a03c89800f16e7aaf13dbd3784045626b672dcf65b
|
|
| MD5 |
d8c2211b58cf53907ed7db965dd0f1a2
|
|
| BLAKE2b-256 |
297702c8f9097213607efcd53d98b8b1189c391745bfdf31821acbe302650168
|