Class for autotests flask python apps
Project description
Class for autotests flask python apps
Install
pip install tester_flask
Usage in tests
from flask import Flask
from tester_flask import TestFlask
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def main_page():
return "Flask OK"
@app.route('/redirect', methods=['POST'])
def redirect_page():
return redirect(url_for('main_page'))
class TestFlaskApp(TestFlask):
def setUp(self):
super(TestFlaskApp, self).setUp()
TestFlask.set_up(self, app)
def test_app(self):
assert self.simple_view('main_page').status_code == 200
assert self.param_post('main_page', {'hello': 1}, {'one': 1}).status_code == 200
response = self.simple_post('redirect_page', {'one': 1}, follow=False)
assert self.final_url(response) == self.get_url('main_page')
Development
git clone git@github.com:vb64/test.helper.flask.git
cd test.helper.flask
With Python 3
make setup PYTHON_BIN="/path/to/python3
make tests
With Python 2
make setup2 PYTHON_BIN="/path/to/python2
make tests2
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tester_flask-1.2.tar.gz
(3.8 kB
view details)
Built Distribution
File details
Details for the file tester_flask-1.2.tar.gz
.
File metadata
- Download URL: tester_flask-1.2.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed8bfa63472d991abb56c8c112166040729bf609d432eaf37813aa1980b60695 |
|
MD5 | ff64b1eee879f6a8b6b4f17ca2b56586 |
|
BLAKE2b-256 | 71e103952b87be892522e10ff2fa5f6635c19ca0405124c798a3606f887ea5a9 |
File details
Details for the file tester_flask-1.2-py3-none-any.whl
.
File metadata
- Download URL: tester_flask-1.2-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b67378c4be57811d2ca26c0c5acad5f31532b105b6c3291c19125f8fa598a76f |
|
MD5 | ef2fecc1d6c603f9d3ed3f475576c67b |
|
BLAKE2b-256 | 654475ab9751d8fcb55392525942b9e713e141cb0e79d8a45e34dec05eaa56f0 |