Skip to content
Myr

Add tests for adding exception to response contents only when DEBUG is True

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Keyan Pishdadian · committed by Keyan Pishdadian · parent 19df249 · Browse files · 1 file+24 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+24 added−0 removed

  • tests:+24 added−0 removed

1 file+24 added−0 removed

modified:tests/test_helpers.py+24 added
47 unmodified lines
48 rv = c.get(url)49 assert rv.mimetype == 'application/json'50 assert flask.json.loads(rv.data)['x'] == http_date(d.timetuple())5152 def test_post_empty_json_adds_exception_to_reponse_content_in_debug(self):53 app = flask.Flask(__name__)54 app.config['DEBUG'] = True55 @app.route('/json', methods=['POST'])56 def post_json():57 flask.request.get_json()58 return None59 c = app.test_client()60 rv = c.post('/json', data=None, content_type='application/json')61 assert rv.status_code == 40062 assert '<p>No JSON object could be decoded</p>' in rv.data6364 def test_post_empty_json_doesnt_add_exception_to_reponse_if_no_debug(self):65 app = flask.Flask(__name__)66 app.config['DEBUG'] = False67 @app.route('/json', methods=['POST'])68 def post_json():69 flask.request.get_json()70 return None71 c = app.test_client()72 rv = c.post('/json', data=None, content_type='application/json')73 assert rv.status_code == 40074 assert '<p>No JSON object could be decoded</p>' not in rv.data7576 def test_json_bad_requests(self):77 app = flask.Flask(__name__)78 @app.route('/json', methods=['POST'])79 def return_json():
601 unmodified lines