Пример #1
0
    def test_re_replace_multi(self):
        r = re_add_variants(u"ae")
        self.assertEqual(r, u"(?:[aàáâãäåāăąǎǟǡǻȁȃȧḁạảấầẩẫậắằẳẵặ]"
                            u"[eèéêëēĕėęěȅȇȩḕḗḙḛḝẹẻẽếềểễệ]|[æǣǽ])")

        r = re_add_variants(u"SS")
        self.assertEqual(r, u"(?:[SŚŜŞŠȘṠṢṤṦṨꞄ][SŚŜŞŠȘṠṢṤṦṨꞄ]|ẞ)")

        r = re_add_variants(u"ss")
        self.assertEqual(r, u"(?:[sśŝşšșṡṣṥṧṩꞅ][sśŝşšșṡṣṥṧṩꞅ]|ß)")
Пример #2
0
    def test_re_replace_multi(self):
        r = re_add_variants(u"ae")
        self.assertEqual(r, u"(?:[aàáâãäåāăąǎǟǡǻȁȃȧḁạảấầẩẫậắằẳẵặ]"
                            u"[eèéêëēĕėęěȅȇȩḕḗḙḛḝẹẻẽếềểễệ]|[æǣǽ])")

        r = re_add_variants(u"SS")
        self.assertEqual(r, u"(?:[SŚŜŞŠȘṠṢṤṦṨꞄ][SŚŜŞŠȘṠṢṤṦṨꞄ]|ẞ)")

        r = re_add_variants(u"ss")
        self.assertEqual(r, u"(?:[sśŝşšșṡṣṥṧṩꞅ][sśŝşšșṡṣṥṧṩꞅ]|ß)")
Пример #3
0
 def test_punct(self):
     r = re_add_variants(u"'")
     assert "`" in r
     assert "'" in r
     r = re_add_variants(u"''")
     assert "\"" in r
     r = re_add_variants(u'"')
     assert "”" in r
     assert "“" in r
     r = re_add_variants(u'\\*')
     assert re.match(r, "*")
Пример #4
0
 def test_punct(self):
     r = re_add_variants(u"'")
     assert "`" in r
     assert "'" in r
     r = re_add_variants(u"''")
     assert "\"" in r
     r = re_add_variants(u'"')
     assert "”" in r
     assert "“" in r
     r = re_add_variants(u'\\*')
     assert re.match(r, "*")
Пример #5
0
 def test_seq(self):
     assert re_add_variants(u"[x-y]") == u"[ẋẍýÿŷȳẏẙỳỵỷỹx-y]"
     assert re_add_variants(u"[f-gm]") == u"[ḟꝼĝğġģǧǵḡᵹf-gmḿṁṃ]"
     assert re_add_variants(u"[^m]") == u"[^mḿṁṃ]"
     assert re_add_variants(u"[^m-m\w]") == u"[^ḿṁṃm-m\w]"
     assert re_add_variants(u"[^m-m]") == "[^ḿṁṃm-m]"
     assert re_add_variants(u"[^ö]") == u"[^ö]"
     assert re_add_variants(u"[LLL]") == u"[LĹĻĽḶḸḺḼŁ]"
Пример #6
0
 def test_seq(self):
     assert re_add_variants(u"[x-y]") == u"[ẋẍýÿŷȳẏẙỳỵỷỹx-y]"
     assert re_add_variants(u"[f-gm]") == u"[ḟꝼĝğġģǧǵḡᵹf-gmḿṁṃ]"
     assert re_add_variants(u"[^m]") == u"[^mḿṁṃ]"
     assert re_add_variants(u"[^m-m\\w]") == u"[^ḿṁṃm-m\\w]"
     assert re_add_variants(u"[^m-m]") == "[^ḿṁṃm-m]"
     assert re_add_variants(u"[^ö]") == u"[^ö]"
     assert re_add_variants(u"[LLL]") == u"[LĹĻĽḶḸḺḼŁ]"
Пример #7
0
 def test_re_replace_escape(self):
     r = re_add_variants(u"n\\n")
     self.assertEqual(r, u"[nñńņňǹṅṇṉṋʼn]\n")
Пример #8
0
 def test_re_replace_multi_nested(self):
     r = re_add_variants(u"(եւ)")
     self.assertEqual(r, u"((?:եւ|և))")
     r = re_add_variants(u"(եւ)+")
     self.assertEqual(r, u"((?:եւ|և))+")
Пример #9
0
 def test_re_replace_multi_fixme(self):
     # we don't handler overlapping sequences, so this doesn't match "LỺ"
     r = re_add_variants(u"LLL")
     self.assertEqual(r, u"(?:[LĹĻĽḶḸḺḼŁ][LĹĻĽḶḸḺḼŁ]|Ỻ)[LĹĻĽḶḸḺḼŁ]")
Пример #10
0
 def test_literal(self):
     assert re_add_variants(u"f") == u"[fḟꝼ]"
     assert u"ø" in re_add_variants(u"o")
     assert u"Ø" in re_add_variants(u"O")
     assert re_add_variants(u"[^f]") == u"[^fḟꝼ]"
Пример #11
0
 def test_normalize_input(self):
     assert re.match(re_add_variants(unicodedata.normalize("NFD", u"ö")),
                     u"ö")
Пример #12
0
 def test_re_replace(self):
     r = re_add_variants(u"aa")
     self.assertTrue(u"[" in r and u"]" in r and r.count(u"ä") == 2)
Пример #13
0
 def test_normalize_input(self):
     assert re.match(
         re_add_variants(unicodedata.normalize("NFD", u"ö")), u"ö")
Пример #14
0
 def test_literal(self):
     assert re_add_variants(u"f") == u"[fḟꝼ]"
     assert u"ø" in re_add_variants(u"o")
     assert u"Ø" in re_add_variants(u"O")
     assert re_add_variants(u"[^f]") == u"[^fḟꝼ]"
Пример #15
0
 def test_re_replace_escape(self):
     r = re_add_variants(u"n\\n")
     self.assertEqual(r, u"[nñńņňǹṅṇṉṋʼn]\n")
Пример #16
0
 def test_re_replace_multi_nested(self):
     r = re_add_variants(u"(եւ)")
     self.assertEqual(r, u"((?:եւ|և))")
     r = re_add_variants(u"(եւ)+")
     self.assertEqual(r, u"((?:եւ|և))+")
Пример #17
0
 def test_re_replace_multi_fixme(self):
     # we don't handler overlapping sequences, so this doesn't match "LỺ"
     r = re_add_variants(u"LLL")
     self.assertEqual(r, u"(?:[LĹĻĽḶḸḺḼŁ][LĹĻĽḶḸḺḼŁ]|Ỻ)[LĹĻĽḶḸḺḼŁ]")
Пример #18
0
 def test_re_replace(self):
     r = re_add_variants(u"aa")
     self.assertTrue(u"[" in r and u"]" in r and r.count(u"ä") == 2)