Chris McDonough
2013-08-30 06f57f4616758f1f05cb0402fc970089d4483f28
fix the regex used by get_remainder_name, add tests for get_remainder_name
2 files modified
13 ■■■■■ changed files
pyramid/tests/test_urldispatch.py 11 ●●●●● patch | view | raw | blame | history
pyramid/urldispatch.py 2 ●●● patch | view | raw | blame | history
pyramid/tests/test_urldispatch.py
@@ -522,6 +522,17 @@
        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):
    """ """
        
pyramid/urldispatch.py
@@ -92,7 +92,7 @@
# 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