Ejemplo n.º 1
0
 def test_mapping(self):
     for ns in NameStyle:
         for trailing in TRAILING_VARIANTS:
             self.assertEqual(
                 convert_name('BadSnakeName', ns,
                              {'BadSnakeName': 'MappedName'}, trailing),
                 'MappedName')
Ejemplo n.º 2
0
    def test_value_error(self):
        for ns in NameStyle:
            if ns is not NameStyle.ignore:
                self.assert_raise_value_error(ns)

        for trailing in TRAILING_VARIANTS:
            self.assertEqual(
                convert_name('BadSnakeName', NameStyle.ignore, None, trailing),
                'BadSnakeName')
Ejemplo n.º 3
0
 def assert_convert(self, name_style: NameStyle, snake_name: str,
                    result_name: str):
     self.assertEqual(result_name,
                      convert_name(snake_name, name_style, None, True))
Ejemplo n.º 4
0
 def assert_raise_value_error(self, name_style: NameStyle):
     for trailing in TRAILING_VARIANTS:
         with self.assertRaises(ValueError):
             convert_name('BadSnakeName', name_style, None, trailing)