예제 #1
0
 def test_nfkc(self):
     self.assertEqual(
         "a",
         nodeprep("\u00AA"),
         "Nodeprep requirement: NFKC")
     self.assertEqual(
         "ix",
         nodeprep("\u2168"),
         "Nodeprep requirement: NFKC")
예제 #2
0
 def test_nfkc(self):
     self.assertEqual(
         "a",
         nodeprep("\u00AA"),
         "Nodeprep requirement: NFKC")
     self.assertEqual(
         "ix",
         nodeprep("\u2168"),
         "Nodeprep requirement: NFKC")
예제 #3
0
    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))
예제 #4
0
    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))
예제 #5
0
    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(">")
예제 #6
0
    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(">")
예제 #7
0
 def test_case_fold(self):
     self.assertEqual("ssa", nodeprep("ßA"),
                      "Nodeprep requirement: map ß to ss, A to a")
예제 #8
0
 def test_map_to_nothing(self):
     self.assertEqual("ix", nodeprep("I\u00ADX"),
                      "Nodeprep requirement: map SOFT HYPHEN to nothing")
예제 #9
0
 def test_case_fold(self):
     self.assertEqual(
         "ssa",
         nodeprep("ßA"),
         "Nodeprep requirement: map ß to ss, A to a")
예제 #10
0
 def test_map_to_nothing(self):
     self.assertEqual(
         "ix",
         nodeprep("I\u00ADX"),
         "Nodeprep requirement: map SOFT HYPHEN to nothing")