added a new behaviour for responses that enable the tuple to be in the form of (response, headers) and continiue to support the (response, status, headers) format.
This commit is contained in:
parent
afd3c4532b
commit
70f8b39c52
3 changed files with 39 additions and 12 deletions
|
|
@ -735,7 +735,17 @@ class BasicFunctionalityTestCase(FlaskTestCase):
|
|||
return 'Meh', 400, {
|
||||
'X-Foo': 'Testing',
|
||||
'Content-Type': 'text/plain; charset=utf-8'
|
||||
}
|
||||
@app.route("/two_args")
|
||||
def from_two_args_tuple():
|
||||
return "Hello", {
|
||||
'X-Foo': 'Test',
|
||||
'Content-Type': 'text/plain; charset=utf-8'
|
||||
}
|
||||
@app.route("/args_status")
|
||||
def from_status_tuple():
|
||||
return "Hi, status!", 400
|
||||
|
||||
c = app.test_client()
|
||||
self.assert_equal(c.get('/unicode').data, u'Hällo Wörld'.encode('utf-8'))
|
||||
self.assert_equal(c.get('/string').data, u'Hällo Wörld'.encode('utf-8'))
|
||||
|
|
@ -745,6 +755,18 @@ class BasicFunctionalityTestCase(FlaskTestCase):
|
|||
self.assert_equal(rv.status_code, 400)
|
||||
self.assert_equal(rv.mimetype, 'text/plain')
|
||||
|
||||
rv2 = c.get("/two_args")
|
||||
self.assert_equal(rv2.data, b'Hello')
|
||||
self.assert_equal(rv2.headers['X-Foo'], 'Test')
|
||||
self.assert_equal(rv2.status_code, 200)
|
||||
self.assert_equal(rv2.mimetype, 'text/plain')
|
||||
|
||||
rv3 = c.get("/args_status")
|
||||
self.assert_equal(rv3.data, b'Hi, status!')
|
||||
self.assert_equal(rv3.status_code, 400)
|
||||
self.assert_equal(rv3.mimetype, 'text/html')
|
||||
|
||||
|
||||
def test_make_response(self):
|
||||
app = flask.Flask(__name__)
|
||||
with app.test_request_context():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue