From 06f57f4616758f1f05cb0402fc970089d4483f28 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 29 Aug 2013 23:03:56 -0400 Subject: fix the regex used by get_remainder_name, add tests for get_remainder_name --- pyramid/tests/test_urldispatch.py | 11 +++++++++++ pyramid/urldispatch.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pyramid/tests/test_urldispatch.py b/pyramid/tests/test_urldispatch.py index 1755d9f47..ba5f2eeb5 100644 --- a/pyramid/tests/test_urldispatch.py +++ b/pyramid/tests/test_urldispatch.py @@ -522,6 +522,17 @@ class TestCompileRouteFunctional(unittest.TestCase): self.generates('/foo/:_abc', {'_abc':'20'}, '/foo/20') self.generates('/foo/:abc_def', {'abc_def':'20'}, '/foo/20') +class Test_get_remainder_name(unittest.TestCase): + def _callFUT(self, pattern): + from pyramid.urldispatch import get_remainder_name + return get_remainder_name(pattern) + + def test_it_nostararg(self): + self.assertEqual(self._callFUT('/bob'), None) + + def test_it_withstararg(self): + self.assertEqual(self._callFUT('/bob*dean'), 'dean') + class DummyContext(object): """ """ diff --git a/pyramid/urldispatch.py b/pyramid/urldispatch.py index 621b6d939..75bff904d 100644 --- a/pyramid/urldispatch.py +++ b/pyramid/urldispatch.py @@ -92,7 +92,7 @@ class RoutesMapper(object): # stolen from bobo and modified old_route_re = re.compile(r'(\:[_a-zA-Z]\w*)') -star_at_end = re.compile(r'(\*\w*)$') +star_at_end = re.compile(r'\*(\w*)$') # The tortuous nature of the regex named ``route_re`` below is due to the # fact that we need to support at least one level of "inner" squigglies -- cgit v1.2.3