def test_nfkc(self): self.assertEqual( "a", nodeprep("\u00AA"), "Nodeprep requirement: NFKC") self.assertEqual( "ix", nodeprep("\u2168"), "Nodeprep requirement: NFKC")
def test_unassigned(self): with self.assertRaises(ValueError, msg="Nodeprep requirement: unassigned"): nodeprep("\u0221", allow_unassigned=False) with self.assertRaises(ValueError, msg="enforce no unassigned by default"): nodeprep("\u0221") self.assertEqual("\u0221", nodeprep("\u0221", allow_unassigned=True))
def test_unassigned(self): with self.assertRaises( ValueError, msg="Nodeprep requirement: unassigned"): nodeprep("\u0221", allow_unassigned=False) with self.assertRaises( ValueError, msg="enforce no unassigned by default"): nodeprep("\u0221") self.assertEqual( "\u0221", nodeprep("\u0221", allow_unassigned=True))
def test_prohibited_character(self): with self.assertRaisesRegex( ValueError, r"U\+0007", msg="Nodeprep requirement: prohibited character (C.2.1)"): nodeprep("\u0007") with self.assertRaisesRegex( ValueError, r"U\+200e", msg="Nodeprep requirement: prohibited character (C.8)"): nodeprep("\u200E") with self.assertRaisesRegex( ValueError, r"U\+003e", msg="Nodeprep requirement: prohibited character (custom)"): nodeprep(">")
def test_case_fold(self): self.assertEqual("ssa", nodeprep("ßA"), "Nodeprep requirement: map ß to ss, A to a")
def test_map_to_nothing(self): self.assertEqual("ix", nodeprep("I\u00ADX"), "Nodeprep requirement: map SOFT HYPHEN to nothing")
def test_case_fold(self): self.assertEqual( "ssa", nodeprep("ßA"), "Nodeprep requirement: map ß to ss, A to a")
def test_map_to_nothing(self): self.assertEqual( "ix", nodeprep("I\u00ADX"), "Nodeprep requirement: map SOFT HYPHEN to nothing")