Exemple #1
0
    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))
Exemple #2
0
    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))
Exemple #3
0
    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")
Exemple #4
0
 def test_case_fold(self):
     self.assertEqual("ssa", nameprep("ßA"),
                      "Nameprep requirement: map ß to ss, A to a")
Exemple #5
0
 def test_map_to_nothing(self):
     self.assertEqual("ix", nameprep("I\u00ADX"),
                      "Nameprep requirement: map SOFT HYPHEN to nothing")
Exemple #6
0
 def test_map_to_nothing(self):
     self.assertEqual(
         "ix",
         nameprep("I\u00ADX"),
         "Nameprep requirement: map SOFT HYPHEN to nothing")
Exemple #7
0
    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")
Exemple #8
0
 def test_case_fold(self):
     self.assertEqual(
         "ssa",
         nameprep("ßA"),
         "Nameprep requirement: map ß to ss, A to a")