def test_unassigned(self): with self.assertRaises(ValueError, msg="Nameprep requirement: unassigned"): nameprep("\u0221", allow_unassigned=False) with self.assertRaises(ValueError, msg="enforce no unassigned by default"): nameprep("\u0221") self.assertEqual("\u0221", nameprep("\u0221", allow_unassigned=True))
def test_unassigned(self): with self.assertRaises( ValueError, msg="Nameprep requirement: unassigned"): nameprep("\u0221", allow_unassigned=False) with self.assertRaises( ValueError, msg="enforce no unassigned by default"): nameprep("\u0221") self.assertEqual( "\u0221", nameprep("\u0221", allow_unassigned=True))
def test_prohibited_character(self): with self.assertRaisesRegex( ValueError, r"U\+06dd", msg="Nameprep requirement: prohibited character (C.2.2)"): nameprep("\u06DD") with self.assertRaisesRegex( ValueError, r"U\+e000", msg="Nameprep requirement: prohibited character (C.3)"): nameprep("\uE000") with self.assertRaisesRegex( ValueError, r"U\+1fffe", msg="Nameprep requirement: prohibited character (C.4)"): nameprep("\U0001FFFE") with self.assertRaisesRegex( ValueError, r"U\+d800", msg="Nameprep requirement: prohibited character (C.5)"): nameprep("\uD800") with self.assertRaisesRegex( ValueError, r"U\+fff9", msg="Nameprep requirement: prohibited character (C.6)"): nameprep("\uFFF9") with self.assertRaisesRegex( ValueError, r"U\+2ff0", msg="Nameprep requirement: prohibited character (C.7)"): nameprep("\u2FF0") with self.assertRaisesRegex( ValueError, r"U\+e0001", msg="Nameprep requirement: prohibited character (C.9)"): nameprep("\U000E0001")
def test_case_fold(self): self.assertEqual("ssa", nameprep("ßA"), "Nameprep requirement: map ß to ss, A to a")
def test_map_to_nothing(self): self.assertEqual("ix", nameprep("I\u00ADX"), "Nameprep requirement: map SOFT HYPHEN to nothing")
def test_map_to_nothing(self): self.assertEqual( "ix", nameprep("I\u00ADX"), "Nameprep requirement: map SOFT HYPHEN to nothing")
def test_case_fold(self): self.assertEqual( "ssa", nameprep("ßA"), "Nameprep requirement: map ß to ss, A to a")