The test client and test_request_context are now both using the same logic internally for creating the environ. Also they use APPLICATION_ROOT now.

This commit is contained in:
Armin Ronacher 2011-08-25 20:47:50 +01:00
parent 1ea3d4ea53
commit e853a0f739
5 changed files with 38 additions and 29 deletions

View file

@ -1042,6 +1042,21 @@ class BasicFunctionalityTestCase(FlaskTestCase):
class TestToolsTestCase(FlaskTestCase):
def test_environ_defaults_from_config(self):
app = flask.Flask(__name__)
app.testing = True
app.config['SERVER_NAME'] = 'example.com:1234'
app.config['APPLICATION_ROOT'] = '/foo'
@app.route('/')
def index():
return flask.request.url
ctx = app.test_request_context()
self.assertEqual(ctx.request.url, 'http://example.com:1234/foo/')
with app.test_client() as c:
rv = c.get('/')
self.assertEqual(rv.data, 'http://example.com:1234/foo/')
def test_session_transactions(self):
app = flask.Flask(__name__)
app.testing = True