Skip to content

jwg4/flask-requests-test-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask Requests Test Client

This package is an alternative to the flask test client, one which has a very similar interface to the requests package. This allows the same tests/monitoring to be re-used against the test client (using this package) and an actual HTTP server (using requests).

>>> from flask import Flask, jsonify
>>> app = Flask(__name__)

>>> @app.route('/hello')
... def hello_world():
...     return jsonify({'msg': 'Hello, World!'})

>>> from frtc import TestClient
>>> client = TestClient(app.test_client())

>>> r = client.get('/hello')
>>> r.status_code
200

>>> r.headers['Content-Type']
'application/json'
>>> r.encoding
>>> r.text  # doctest: +ALLOW_UNICODE
'{\n  "msg": "Hello, World!"\n}\n'
>>> r.json()  # doctest: +ALLOW_UNICODE
{'msg': 'Hello, World!'}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages