Exemple #1
0
 def test_macro(self):
     surlex = '/year/<:Y>.html'
     regex = '/year/\d{4}\.html'
     self.assertEqual(surl(surlex), regex)
Exemple #2
0
 def test_basic_capture1(self):
     surlex = '/<var>/'
     regex = '/(?P<var>.+)/'
     self.assertEqual(surl(surlex), regex)
Exemple #3
0
 def test_basic_capture2(self):
     surlex = '/<product>/<option>.html'
     regex = '/(?P<product>.+)/(?P<option>.+)\.html'
     self.assertEqual(surl(surlex), regex)
Exemple #4
0
 def test_regex2(self):
     surlex = r'/<=\d{5}$>'
     regex = r'/\d{5}$'
     self.assertEqual(surl(surlex), regex)
Exemple #5
0
 def test_basic_capture1(self):
     surlex = '/<var>/'
     regex = '/(?P<var>.+)/'
     self.assertEqual(surl(surlex), regex)
Exemple #6
0
 def test_regex_capture(self):
     surlex = '/<var=[0-9]*>/'
     regex = '/(?P<var>[0-9]*)/'
     self.assertEqual(surl(surlex), regex)
Exemple #7
0
 def test_wildcard(self):
     surlex = '/foo/*.html'
     regex = '/foo/.*\.html'
     self.assertEqual(surl(surlex), regex)
Exemple #8
0
 def test_optional(self):
     surlex = '/things/(<slug>/)'
     regex = '/things/((?P<slug>.+)/)?'
     self.assertEqual(surl(surlex), regex)
Exemple #9
0
 def test_wildcard(self):
     surlex = '/foo/*.html'
     regex = '/foo/.*\.html'
     self.assertEqual(surl(surlex), regex)
Exemple #10
0
 def test_custom_macro(self):
     register_macro('B', 'bar')
     surlex = '/foo/<:B>/'
     regex = '/foo/bar/'
     self.assertEqual(surl(surlex), regex)
Exemple #11
0
 def test_regex_capture(self):
     surlex = '/<var=[0-9]*>/'
     regex = '/(?P<var>[0-9]*)/'
     self.assertEqual(surl(surlex), regex)
Exemple #12
0
 def test_macro_capture(self):
     surlex = '/blog/<year:Y>.html'
     regex = '/blog/(?P<year>\d{4})\.html'
     self.assertEqual(surl(surlex), regex)
Exemple #13
0
 def test_macro(self):
     surlex = '/year/<:Y>.html'
     regex = '/year/\d{4}\.html'
     self.assertEqual(surl(surlex), regex)
Exemple #14
0
 def test_basic_capture2(self):
     surlex = '/<product>/<option>.html'
     regex = '/(?P<product>.+)/(?P<option>.+)\.html'
     self.assertEqual(surl(surlex), regex)
Exemple #15
0
 def test_macro_capture(self):
     surlex = '/blog/<year:Y>.html'
     regex = '/blog/(?P<year>\d{4})\.html'
     self.assertEqual(surl(surlex), regex)
Exemple #16
0
 def test_regex(self):
     surlex = '/anything/<=.*$>'
     regex = '/anything/.*$'
     self.assertEqual(surl(surlex), regex)
Exemple #17
0
 def test_custom_macro(self):
     register_macro('B', 'bar')
     surlex = '/foo/<:B>/'
     regex = '/foo/bar/'
     self.assertEqual(surl(surlex), regex)
Exemple #18
0
 def test_regex2(self):
     surlex = r'/<=\d{5}$>'
     regex = r'/\d{5}$'
     self.assertEqual(surl(surlex), regex)
Exemple #19
0
 def test_optional(self):
     surlex = '/things/(<slug>/)'
     regex = '/things/((?P<slug>.+)/)?'
     self.assertEqual(surl(surlex), regex)
Exemple #20
0
 def test_regex3(self):
     surlex = '<=\>>'
     regex = '>'
     self.assertEqual(surl(surlex), regex)
Exemple #21
0
 def test_regex(self):
     surlex = '/anything/<=.*$>'
     regex = '/anything/.*$'
     self.assertEqual(surl(surlex), regex)
Exemple #22
0
 def test_matches(self):
     for surlex, regex in self.matches:
         self.assertEqual(surl(surlex), regex)
Exemple #23
0
 def test_regex3(self):
     surlex = '<=\>>'
     regex = '>'
     self.assertEqual(surl(surlex), regex)
Exemple #24
0
 def test_matches(self):
     for surlex, regex in self.matches:
         self.assertEqual(surl(surlex), regex)