Browse Source

Test that dotted names work. This fixes #258

pull/262/head
Armin Ronacher 14 years ago
parent
commit
ea7a172077
  1. 2
      flask/wrappers.py
  2. 25
      tests/flask_tests.py

2
flask/wrappers.py

@ -80,7 +80,7 @@ class Request(RequestBase):
def blueprint(self):
"""The name of the current blueprint"""
if self.url_rule and '.' in self.url_rule.endpoint:
return self.url_rule.endpoint.split('.', 1)[0]
return self.url_rule.endpoint.rsplit('.', 1)[0]
@cached_property
def json(self):

25
tests/flask_tests.py

@ -1323,6 +1323,31 @@ class BlueprintTestCase(unittest.TestCase):
with flask.Flask(__name__).test_request_context():
assert flask.render_template('nested/nested.txt') == 'I\'m nested'
def test_dotted_names(self):
frontend = flask.Blueprint('myapp.frontend', __name__)
backend = flask.Blueprint('myapp.backend', __name__)
@frontend.route('/fe')
def frontend_index():
return flask.url_for('myapp.backend.backend_index')
@frontend.route('/fe2')
def frontend_page2():
return flask.url_for('.frontend_index')
@backend.route('/be')
def backend_index():
return flask.url_for('myapp.frontend.frontend_index')
app = flask.Flask(__name__)
app.register_blueprint(frontend)
app.register_blueprint(backend)
c = app.test_client()
self.assertEqual(c.get('/fe').data.strip(), '/be')
self.assertEqual(c.get('/fe2').data.strip(), '/fe')
self.assertEqual(c.get('/be').data.strip(), '/fe')
class SendfileTestCase(unittest.TestCase):

Loading…
Cancel
Save