forked from orbit-oss/flask
If JSON parsing fails it now issues a BadRequest exception.
This commit is contained in:
parent
acac64e36a
commit
ce70131975
4 changed files with 36 additions and 4 deletions
|
|
@ -984,6 +984,15 @@ class BasicFunctionalityTestCase(unittest.TestCase):
|
|||
|
||||
class JSONTestCase(unittest.TestCase):
|
||||
|
||||
def test_json_bad_requests(self):
|
||||
app = flask.Flask(__name__)
|
||||
@app.route('/json', methods=['POST'])
|
||||
def return_json():
|
||||
return unicode(flask.request.json)
|
||||
c = app.test_client()
|
||||
rv = c.post('/json', data='malformed', content_type='application/json')
|
||||
self.assertEqual(rv.status_code, 400)
|
||||
|
||||
def test_json_body_encoding(self):
|
||||
app = flask.Flask(__name__)
|
||||
app.testing = True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue