Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ext_arabic_digit = u'\u06f0'
# RFC 5892 Rule A.3 (Middle Dot)
latin_middle_dot = u'\u00b7'
self.assertTrue(idna.valid_contexto(latin_l + latin_middle_dot + latin_l, 1))
self.assertFalse(idna.valid_contexto(latin_middle_dot + latin_l, 1))
self.assertFalse(idna.valid_contexto(latin_l + latin_middle_dot, 0))
self.assertFalse(idna.valid_contexto(latin_middle_dot, 0))
self.assertFalse(idna.valid_contexto(latin_l + latin_middle_dot + latin, 1))
# RFC 5892 Rule A.4 (Greek Lower Numeral Sign)
glns = u'\u0375'
self.assertTrue(idna.valid_contexto(glns + greek, 0))
self.assertFalse(idna.valid_contexto(glns + latin, 0))
self.assertFalse(idna.valid_contexto(glns, 0))
self.assertFalse(idna.valid_contexto(greek + glns, 1))
# RFC 5892 Rule A.5 (Hebrew Punctuation Geresh)
geresh = u'\u05f3'
self.assertTrue(idna.valid_contexto(hebrew + geresh, 1))
self.assertFalse(idna.valid_contexto(latin + geresh, 1))
# RFC 5892 Rule A.6 (Hebrew Punctuation Gershayim)
gershayim = u'\u05f4'
self.assertTrue(idna.valid_contexto(hebrew + gershayim, 1))
self.assertFalse(idna.valid_contexto(latin + gershayim, 1))
# RFC 5892 Rule A.7 (Katakana Middle Dot)
ja_middle_dot = u'\u30fb'
self.assertTrue(idna.valid_contexto(katakana + ja_middle_dot + katakana, 1))
self.assertTrue(idna.valid_contexto(hiragana + ja_middle_dot + hiragana, 1))
self.assertTrue(idna.valid_contexto(han + ja_middle_dot + han, 1))
# RFC 5892 Rule A.6 (Hebrew Punctuation Gershayim)
gershayim = u'\u05f4'
self.assertTrue(idna.valid_contexto(hebrew + gershayim, 1))
self.assertFalse(idna.valid_contexto(latin + gershayim, 1))
# RFC 5892 Rule A.7 (Katakana Middle Dot)
ja_middle_dot = u'\u30fb'
self.assertTrue(idna.valid_contexto(katakana + ja_middle_dot + katakana, 1))
self.assertTrue(idna.valid_contexto(hiragana + ja_middle_dot + hiragana, 1))
self.assertTrue(idna.valid_contexto(han + ja_middle_dot + han, 1))
self.assertTrue(idna.valid_contexto(han + ja_middle_dot + latin, 1))
self.assertTrue(idna.valid_contexto(u'\u6f22\u30fb\u5b57', 1))
self.assertFalse(idna.valid_contexto(u'\u0061\u30fb\u0061', 1))
# RFC 5892 Rule A.8 (Arabic-Indic Digits)
self.assertTrue(idna.valid_contexto(arabic_digit + arabic_digit, 0))
self.assertFalse(idna.valid_contexto(arabic_digit + ext_arabic_digit, 0))
# RFC 5892 Rule A.9 (Extended Arabic-Indic Digits)
self.assertTrue(idna.valid_contexto(ext_arabic_digit + ext_arabic_digit, 0))
self.assertFalse(idna.valid_contexto(ext_arabic_digit + arabic_digit, 0))
arabic_digit = u'\u0660'
ext_arabic_digit = u'\u06f0'
# RFC 5892 Rule A.3 (Middle Dot)
latin_middle_dot = u'\u00b7'
self.assertTrue(idna.valid_contexto(latin_l + latin_middle_dot + latin_l, 1))
self.assertFalse(idna.valid_contexto(latin_middle_dot + latin_l, 1))
self.assertFalse(idna.valid_contexto(latin_l + latin_middle_dot, 0))
self.assertFalse(idna.valid_contexto(latin_middle_dot, 0))
self.assertFalse(idna.valid_contexto(latin_l + latin_middle_dot + latin, 1))
# RFC 5892 Rule A.4 (Greek Lower Numeral Sign)
glns = u'\u0375'
self.assertTrue(idna.valid_contexto(glns + greek, 0))
self.assertFalse(idna.valid_contexto(glns + latin, 0))
self.assertFalse(idna.valid_contexto(glns, 0))
self.assertFalse(idna.valid_contexto(greek + glns, 1))
# RFC 5892 Rule A.5 (Hebrew Punctuation Geresh)
geresh = u'\u05f3'
self.assertTrue(idna.valid_contexto(hebrew + geresh, 1))
self.assertFalse(idna.valid_contexto(latin + geresh, 1))
# RFC 5892 Rule A.6 (Hebrew Punctuation Gershayim)
gershayim = u'\u05f4'
self.assertTrue(idna.valid_contexto(hebrew + gershayim, 1))
self.assertFalse(idna.valid_contexto(latin + gershayim, 1))
# RFC 5892 Rule A.7 (Katakana Middle Dot)
ja_middle_dot = u'\u30fb'
self.assertTrue(idna.valid_contexto(katakana + ja_middle_dot + katakana, 1))
self.assertTrue(idna.valid_contexto(hiragana + ja_middle_dot + hiragana, 1))
self.assertTrue(idna.valid_contexto(hebrew + geresh, 1))
self.assertFalse(idna.valid_contexto(latin + geresh, 1))
# RFC 5892 Rule A.6 (Hebrew Punctuation Gershayim)
gershayim = u'\u05f4'
self.assertTrue(idna.valid_contexto(hebrew + gershayim, 1))
self.assertFalse(idna.valid_contexto(latin + gershayim, 1))
# RFC 5892 Rule A.7 (Katakana Middle Dot)
ja_middle_dot = u'\u30fb'
self.assertTrue(idna.valid_contexto(katakana + ja_middle_dot + katakana, 1))
self.assertTrue(idna.valid_contexto(hiragana + ja_middle_dot + hiragana, 1))
self.assertTrue(idna.valid_contexto(han + ja_middle_dot + han, 1))
self.assertTrue(idna.valid_contexto(han + ja_middle_dot + latin, 1))
self.assertTrue(idna.valid_contexto(u'\u6f22\u30fb\u5b57', 1))
self.assertFalse(idna.valid_contexto(u'\u0061\u30fb\u0061', 1))
# RFC 5892 Rule A.8 (Arabic-Indic Digits)
self.assertTrue(idna.valid_contexto(arabic_digit + arabic_digit, 0))
self.assertFalse(idna.valid_contexto(arabic_digit + ext_arabic_digit, 0))
# RFC 5892 Rule A.9 (Extended Arabic-Indic Digits)
self.assertTrue(idna.valid_contexto(ext_arabic_digit + ext_arabic_digit, 0))
self.assertFalse(idna.valid_contexto(ext_arabic_digit + arabic_digit, 0))
han = u'\u6f22'
arabic_digit = u'\u0660'
ext_arabic_digit = u'\u06f0'
# RFC 5892 Rule A.3 (Middle Dot)
latin_middle_dot = u'\u00b7'
self.assertTrue(idna.valid_contexto(latin_l + latin_middle_dot + latin_l, 1))
self.assertFalse(idna.valid_contexto(latin_middle_dot + latin_l, 1))
self.assertFalse(idna.valid_contexto(latin_l + latin_middle_dot, 0))
self.assertFalse(idna.valid_contexto(latin_middle_dot, 0))
self.assertFalse(idna.valid_contexto(latin_l + latin_middle_dot + latin, 1))
# RFC 5892 Rule A.4 (Greek Lower Numeral Sign)
glns = u'\u0375'
self.assertTrue(idna.valid_contexto(glns + greek, 0))
self.assertFalse(idna.valid_contexto(glns + latin, 0))
self.assertFalse(idna.valid_contexto(glns, 0))
self.assertFalse(idna.valid_contexto(greek + glns, 1))
# RFC 5892 Rule A.5 (Hebrew Punctuation Geresh)
geresh = u'\u05f3'
self.assertTrue(idna.valid_contexto(hebrew + geresh, 1))
self.assertFalse(idna.valid_contexto(latin + geresh, 1))
# RFC 5892 Rule A.6 (Hebrew Punctuation Gershayim)
gershayim = u'\u05f4'
self.assertTrue(idna.valid_contexto(hebrew + gershayim, 1))
self.assertFalse(idna.valid_contexto(latin + gershayim, 1))
# RFC 5892 Rule A.7 (Katakana Middle Dot)
ja_middle_dot = u'\u30fb'
self.assertTrue(idna.valid_contexto(katakana + ja_middle_dot + katakana, 1))
self.assertTrue(idna.valid_contexto(latin_l + latin_middle_dot + latin_l, 1))
self.assertFalse(idna.valid_contexto(latin_middle_dot + latin_l, 1))
self.assertFalse(idna.valid_contexto(latin_l + latin_middle_dot, 0))
self.assertFalse(idna.valid_contexto(latin_middle_dot, 0))
self.assertFalse(idna.valid_contexto(latin_l + latin_middle_dot + latin, 1))
# RFC 5892 Rule A.4 (Greek Lower Numeral Sign)
glns = u'\u0375'
self.assertTrue(idna.valid_contexto(glns + greek, 0))
self.assertFalse(idna.valid_contexto(glns + latin, 0))
self.assertFalse(idna.valid_contexto(glns, 0))
self.assertFalse(idna.valid_contexto(greek + glns, 1))
# RFC 5892 Rule A.5 (Hebrew Punctuation Geresh)
geresh = u'\u05f3'
self.assertTrue(idna.valid_contexto(hebrew + geresh, 1))
self.assertFalse(idna.valid_contexto(latin + geresh, 1))
# RFC 5892 Rule A.6 (Hebrew Punctuation Gershayim)
gershayim = u'\u05f4'
self.assertTrue(idna.valid_contexto(hebrew + gershayim, 1))
self.assertFalse(idna.valid_contexto(latin + gershayim, 1))
# RFC 5892 Rule A.7 (Katakana Middle Dot)
ja_middle_dot = u'\u30fb'
self.assertTrue(idna.valid_contexto(katakana + ja_middle_dot + katakana, 1))
self.assertTrue(idna.valid_contexto(hiragana + ja_middle_dot + hiragana, 1))
self.assertTrue(idna.valid_contexto(han + ja_middle_dot + han, 1))
self.assertTrue(idna.valid_contexto(han + ja_middle_dot + latin, 1))
self.assertTrue(idna.valid_contexto(u'\u6f22\u30fb\u5b57', 1))
self.assertFalse(idna.valid_contexto(u'\u0061\u30fb\u0061', 1))
latin = u'\u0061'
latin_l = u'\u006c'
greek = u'\u03b1'
hebrew = u'\u05d0'
katakana = u'\u30a1'
hiragana = u'\u3041'
han = u'\u6f22'
arabic_digit = u'\u0660'
ext_arabic_digit = u'\u06f0'
# RFC 5892 Rule A.3 (Middle Dot)
latin_middle_dot = u'\u00b7'
self.assertTrue(idna.valid_contexto(latin_l + latin_middle_dot + latin_l, 1))
self.assertFalse(idna.valid_contexto(latin_middle_dot + latin_l, 1))
self.assertFalse(idna.valid_contexto(latin_l + latin_middle_dot, 0))
self.assertFalse(idna.valid_contexto(latin_middle_dot, 0))
self.assertFalse(idna.valid_contexto(latin_l + latin_middle_dot + latin, 1))
# RFC 5892 Rule A.4 (Greek Lower Numeral Sign)
glns = u'\u0375'
self.assertTrue(idna.valid_contexto(glns + greek, 0))
self.assertFalse(idna.valid_contexto(glns + latin, 0))
self.assertFalse(idna.valid_contexto(glns, 0))
self.assertFalse(idna.valid_contexto(greek + glns, 1))
# RFC 5892 Rule A.5 (Hebrew Punctuation Geresh)
geresh = u'\u05f3'
self.assertTrue(idna.valid_contexto(hebrew + geresh, 1))
self.assertFalse(idna.valid_contexto(latin + geresh, 1))
# RFC 5892 Rule A.6 (Hebrew Punctuation Gershayim)
gershayim = u'\u05f4'
geresh = u'\u05f3'
self.assertTrue(idna.valid_contexto(hebrew + geresh, 1))
self.assertFalse(idna.valid_contexto(latin + geresh, 1))
# RFC 5892 Rule A.6 (Hebrew Punctuation Gershayim)
gershayim = u'\u05f4'
self.assertTrue(idna.valid_contexto(hebrew + gershayim, 1))
self.assertFalse(idna.valid_contexto(latin + gershayim, 1))
# RFC 5892 Rule A.7 (Katakana Middle Dot)
ja_middle_dot = u'\u30fb'
self.assertTrue(idna.valid_contexto(katakana + ja_middle_dot + katakana, 1))
self.assertTrue(idna.valid_contexto(hiragana + ja_middle_dot + hiragana, 1))
self.assertTrue(idna.valid_contexto(han + ja_middle_dot + han, 1))
self.assertTrue(idna.valid_contexto(han + ja_middle_dot + latin, 1))
self.assertTrue(idna.valid_contexto(u'\u6f22\u30fb\u5b57', 1))
self.assertFalse(idna.valid_contexto(u'\u0061\u30fb\u0061', 1))
# RFC 5892 Rule A.8 (Arabic-Indic Digits)
self.assertTrue(idna.valid_contexto(arabic_digit + arabic_digit, 0))
self.assertFalse(idna.valid_contexto(arabic_digit + ext_arabic_digit, 0))
# RFC 5892 Rule A.9 (Extended Arabic-Indic Digits)
self.assertTrue(idna.valid_contexto(ext_arabic_digit + ext_arabic_digit, 0))
self.assertFalse(idna.valid_contexto(ext_arabic_digit + arabic_digit, 0))