forked from orbit-oss/flask
Updated tests
This commit is contained in:
parent
e71a5ff8de
commit
ba6bf23e0d
1 changed files with 13 additions and 33 deletions
|
|
@ -398,37 +398,6 @@ class BasicFunctionalityTestCase(unittest.TestCase):
|
||||||
assert 'after' in evts
|
assert 'after' in evts
|
||||||
assert rv == 'request|after'
|
assert rv == 'request|after'
|
||||||
|
|
||||||
def test_after_request_errors(self):
|
|
||||||
app = flask.Flask(__name__)
|
|
||||||
called = []
|
|
||||||
@app.after_request
|
|
||||||
def after_request(response):
|
|
||||||
called.append(True)
|
|
||||||
return response
|
|
||||||
@app.route('/')
|
|
||||||
def fails():
|
|
||||||
1/0
|
|
||||||
rv = app.test_client().get('/')
|
|
||||||
assert rv.status_code == 500
|
|
||||||
assert 'Internal Server Error' in rv.data
|
|
||||||
assert len(called) == 1
|
|
||||||
|
|
||||||
def test_after_request_handler_error(self):
|
|
||||||
called = []
|
|
||||||
app = flask.Flask(__name__)
|
|
||||||
@app.after_request
|
|
||||||
def after_request(response):
|
|
||||||
called.append(True)
|
|
||||||
1/0
|
|
||||||
return response
|
|
||||||
@app.route('/')
|
|
||||||
def fails():
|
|
||||||
1/0
|
|
||||||
rv = app.test_client().get('/')
|
|
||||||
assert rv.status_code == 500
|
|
||||||
assert 'Internal Server Error' in rv.data
|
|
||||||
assert len(called) == 1
|
|
||||||
|
|
||||||
def test_teardown_request_handler(self):
|
def test_teardown_request_handler(self):
|
||||||
called = []
|
called = []
|
||||||
app = flask.Flask(__name__)
|
app = flask.Flask(__name__)
|
||||||
|
|
@ -460,7 +429,6 @@ class BasicFunctionalityTestCase(unittest.TestCase):
|
||||||
assert 'Response' in rv.data
|
assert 'Response' in rv.data
|
||||||
assert len(called) == 1
|
assert len(called) == 1
|
||||||
|
|
||||||
|
|
||||||
def test_teardown_request_handler_error(self):
|
def test_teardown_request_handler_error(self):
|
||||||
called = []
|
called = []
|
||||||
app = flask.Flask(__name__)
|
app = flask.Flask(__name__)
|
||||||
|
|
@ -494,7 +462,6 @@ class BasicFunctionalityTestCase(unittest.TestCase):
|
||||||
assert 'Internal Server Error' in rv.data
|
assert 'Internal Server Error' in rv.data
|
||||||
assert len(called) == 2
|
assert len(called) == 2
|
||||||
|
|
||||||
|
|
||||||
def test_before_after_request_order(self):
|
def test_before_after_request_order(self):
|
||||||
called = []
|
called = []
|
||||||
app = flask.Flask(__name__)
|
app = flask.Flask(__name__)
|
||||||
|
|
@ -547,6 +514,19 @@ class BasicFunctionalityTestCase(unittest.TestCase):
|
||||||
assert rv.status_code == 500
|
assert rv.status_code == 500
|
||||||
assert 'internal server error' == rv.data
|
assert 'internal server error' == rv.data
|
||||||
|
|
||||||
|
def test_teardown_on_pop(self):
|
||||||
|
buffer = []
|
||||||
|
app = flask.Flask(__name__)
|
||||||
|
@app.teardown_request
|
||||||
|
def end_of_request(exception):
|
||||||
|
buffer.append(exception)
|
||||||
|
|
||||||
|
ctx = app.test_request_context()
|
||||||
|
ctx.push()
|
||||||
|
assert buffer == []
|
||||||
|
ctx.pop()
|
||||||
|
assert buffer == [None]
|
||||||
|
|
||||||
def test_response_creation(self):
|
def test_response_creation(self):
|
||||||
app = flask.Flask(__name__)
|
app = flask.Flask(__name__)
|
||||||
@app.route('/unicode')
|
@app.route('/unicode')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue