Skip to content
Myr

Fixed class-based views support

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Serge S. Koval · committed by Serge S. Koval · parent c9337c0 · Browse files · 2 files+30 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+30 added−1 removed

  • other:+30 added−1 removed

2 files+30 added−1 removed

modified:flask/testsuite/basic.py+29 added
1215 unmodified lines
1216 self.assert_equal(rv.data, b'Test')1217 rv = c.get('/outside', 'http://xtesting.localhost/')1218 self.assert_equal(rv.data, b'Outside')12191220 def test_multi_route_rules(self):1221 app = flask.Flask(__name__)12221223 @app.route('/')1224 @app.route('/<test>/')1225 def index(test='a'):1226 return test12271228 rv = app.test_client().open('/')1229 self.assert_equal(rv.data, b'a')1230 rv = app.test_client().open('/b/')1231 self.assert_equal(rv.data, b'b')12321233 def test_multi_route_class_views(self):1234 class View(object):1235 def __init__(self, app):1236 app.add_url_rule('/', 'index', self.index)1237 app.add_url_rule('/<test>/', 'index', self.index)12381239 def index(self, test='a'):1240 return test12411242 app = flask.Flask(__name__)1243 _ = View(app)1244 rv = app.test_client().open('/')1245 self.assert_equal(rv.data, b'a')1246 rv = app.test_client().open('/b/')1247 self.assert_equal(rv.data, b'b')124812491250def suite():1251 suite = unittest.TestSuite()1252 suite.addTest(unittest.makeSuite(BasicFunctionalityTestCase))1253 suite.addTest(unittest.makeSuite(SubdomainTestCase))
1 unmodified line
modified:flask/app.py+1 added-1 removed
977 unmodified lines
978979 self.url_map.add(rule)980 if view_func is not None:981 old_func = self.view_functions.get(endpoint)982 if old_func is not None and old_func is not view_func:982 if old_func is not None and old_func != view_func:983 raise AssertionError('View function mapping is overwriting an '984 'existing endpoint function: %s' % endpoint)985 self.view_functions[endpoint] = view_func986
856 unmodified lines