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 hashes)
Built Distribution
Close
Hashes for tester_flask-1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b67378c4be57811d2ca26c0c5acad5f31532b105b6c3291c19125f8fa598a76f |
|
MD5 | ef2fecc1d6c603f9d3ed3f475576c67b |
|
BLAKE2b-256 | 654475ab9751d8fcb55392525942b9e713e141cb0e79d8a45e34dec05eaa56f0 |