File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -67,11 +67,16 @@ def convert_camel_case_to_snake(graphql_name: str) -> str:
67
67
i < max_index
68
68
and graphql_name [i ] != c
69
69
and graphql_name [i + 1 ] == lowered_name [i + 1 ]
70
+ and graphql_name [i + 1 ] != "_"
70
71
)
71
72
# test134 -> test_134
72
73
or (c .isdigit () and not graphql_name [i - 1 ].isdigit ())
73
74
# 134test -> 134_test
74
- or (not c .isdigit () and graphql_name [i - 1 ].isdigit ())
75
+ or (
76
+ not c .isdigit ()
77
+ and graphql_name [i ] != "_"
78
+ and graphql_name [i - 1 ].isdigit ()
79
+ )
75
80
):
76
81
python_name += "_"
77
82
python_name += c
Original file line number Diff line number Diff line change @@ -42,6 +42,18 @@ def test_no_underscore_added_if_previous_character_is_an_underscore():
42
42
assert convert_camel_case_to_snake ("test__complexName" ) == "test__complex_name"
43
43
44
44
45
+ @pytest .mark .parametrize (
46
+ ("test_str" , "result" ),
47
+ [
48
+ ("FOO_bar" , "foo_bar" ),
49
+ ("FOO_BAR" , "foo_bar" ),
50
+ ("S3_BUCKET" , "s_3_bucket" ),
51
+ ],
52
+ )
53
+ def test_no_underscore_added_if_next_character_is_an_underscore (test_str , result ):
54
+ assert convert_camel_case_to_snake (test_str ) == result
55
+
56
+
45
57
def test_no_underscore_added_if_previous_character_is_uppercase ():
46
58
assert convert_camel_case_to_snake ("testWithUPPERPart" ) == "test_with_upper_part"
47
59
You can’t perform that action at this time.
0 commit comments