예제 #1
0
 def test_unicode_equivalence(self):
     assert compile(u"\u212B")(u"\u00C5")
     assert compile(u"\u00C5")(u"\u212B")
     assert compile(u"A\u030a")(u"\u00C5")
     assert compile(u"A\u030a")(u"\u212B")
     assert compile(u"o\u0308")(u"o\u0308")
     assert compile(u"o\u0308")(u"\xf6")
     assert compile(u"\xf6")(u"o\u0308")
예제 #2
0
 def test_unicode_equivalence(self):
     assert compile(u"\u212B")(u"\u00C5")
     assert compile(u"\u00C5")(u"\u212B")
     assert compile(u"A\u030a")(u"\u00C5")
     assert compile(u"A\u030a")(u"\u212B")
     assert compile(u"o\u0308")(u"o\u0308")
     assert compile(u"o\u0308")(u"\xf6")
     assert compile(u"\xf6")(u"o\u0308")
예제 #3
0
    def __init__(self, pattern, mod_string):
        self.pattern = text_type(pattern)
        self.mod_string = text_type(mod_string)

        ignore_case = "c" not in self.mod_string or "i" in self.mod_string
        dot_all = "s" in self.mod_string
        asym = "d" in self.mod_string
        try:
            self.search = compile(self.pattern, ignore_case, dot_all, asym)
        except ValueError:
            raise ParseError(
                "The regular expression /%s/ is invalid." % self.pattern)
예제 #4
0
    def test_invalid(self):
        with self.assertRaises(ValueError):
            compile(u"(F", asym=False)

        with self.assertRaises(ValueError):
            compile(u"(F", asym=True)
예제 #5
0
 def test_assert_asym_unicode_equivalence(self):
     assert compile(u"A", asym=True)(u"\u00C5")
     assert compile(u"A\u030a", asym=True)(u"\u212B")
     assert compile(u"\u00C5", asym=True)(u"\u212B")
     assert compile(u"\u212B", asym=True)(u"\u00C5")
예제 #6
0
 def test_assert_asym(self):
     assert compile(u"o", asym=True)(u"ö")
     assert not compile(u"o", asym=False)(u"ö")
예제 #7
0
 def test_assert_dot_all(self):
     assert compile(u"a.b", dot_all=True)(u"a\nb")
     assert not compile(u"a.b", dot_all=False)(u"a\nb")
     assert compile(u"a.b", dot_all=False)(u"a b")
예제 #8
0
 def test_ignore_case(self):
     assert compile(u"foo", ignore_case=True)(u"Foo")
     assert not compile(u"foo", ignore_case=False)(u"Foo")
예제 #9
0
 def test_basics_default(self):
     assert compile(u"foo")(u"foo")
     assert compile(u"foo")(u"fooo")
     assert not compile(u"foo")(u"fo")
예제 #10
0
    def test_invalid(self):
        with self.assertRaises(ValueError):
            compile(u"(F", asym=False)

        with self.assertRaises(ValueError):
            compile(u"(F", asym=True)
예제 #11
0
 def test_assert_asym_unicode_equivalence(self):
     assert compile(u"A", asym=True)(u"\u00C5")
     assert compile(u"A\u030a", asym=True)(u"\u212B")
     assert compile(u"\u00C5", asym=True)(u"\u212B")
     assert compile(u"\u212B", asym=True)(u"\u00C5")
예제 #12
0
 def test_assert_asym(self):
     assert compile(u"o", asym=True)(u"ö")
     assert not compile(u"o", asym=False)(u"ö")
예제 #13
0
 def test_assert_dot_all(self):
     assert compile(u"a.b", dot_all=True)(u"a\nb")
     assert not compile(u"a.b", dot_all=False)(u"a\nb")
     assert compile(u"a.b", dot_all=False)(u"a b")
예제 #14
0
 def test_ignore_case(self):
     assert compile(u"foo", ignore_case=True)(u"Foo")
     assert not compile(u"foo", ignore_case=False)(u"Foo")
예제 #15
0
 def test_basics_default(self):
     assert compile(u"foo")(u"foo")
     assert compile(u"foo")(u"fooo")
     assert not compile(u"foo")(u"fo")