forked from orbit-oss/flask
Added more tests for the new stack behavior.
This commit is contained in:
parent
307d1bc4e5
commit
f8f2e2dff4
3 changed files with 33 additions and 2 deletions
|
|
@ -18,7 +18,7 @@ from flask.testsuite import FlaskTestCase
|
|||
|
||||
class AppContextTestCase(FlaskTestCase):
|
||||
|
||||
def test_basic_support(self):
|
||||
def test_basic_url_generation(self):
|
||||
app = flask.Flask(__name__)
|
||||
app.config['SERVER_NAME'] = 'localhost'
|
||||
app.config['PREFERRED_URL_SCHEME'] = 'https'
|
||||
|
|
@ -31,6 +31,28 @@ class AppContextTestCase(FlaskTestCase):
|
|||
rv = flask.url_for('index')
|
||||
self.assert_equal(rv, 'https://localhost/')
|
||||
|
||||
def test_url_generation_requires_server_name(self):
|
||||
app = flask.Flask(__name__)
|
||||
with app.app_context():
|
||||
with self.assert_raises(RuntimeError):
|
||||
flask.url_for('index')
|
||||
|
||||
def test_url_generation_without_context_fails(self):
|
||||
with self.assert_raises(RuntimeError):
|
||||
flask.url_for('index')
|
||||
|
||||
def test_request_context_means_app_context(self):
|
||||
app = flask.Flask(__name__)
|
||||
with app.test_request_context():
|
||||
self.assert_equal(flask.current_app._get_current_object(), app)
|
||||
self.assert_equal(flask._app_ctx_stack.top, None)
|
||||
|
||||
def test_app_context_provides_current_app(self):
|
||||
app = flask.Flask(__name__)
|
||||
with app.app_context():
|
||||
self.assert_equal(flask.current_app._get_current_object(), app)
|
||||
self.assert_equal(flask._app_ctx_stack.top, None)
|
||||
|
||||
|
||||
def suite():
|
||||
suite = unittest.TestSuite()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue