-
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b9e686
commit d358064
Showing
2 changed files
with
54 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from praw.util import camel_to_snake, snake_case_keys | ||
|
||
from .. import UnitTest | ||
|
||
|
||
class TestSnake(UnitTest): | ||
def test_camel_to_snake(self): | ||
test_strings = ( | ||
("camelCase", "camel_case"), | ||
("PascalCase", "pascal_case"), | ||
("camelCasePlace", "camel_case_place"), | ||
("Pascal8Camel8Snake", "pascal8_camel8_snake"), | ||
("HTTPResponseCode", "http_response_code"), | ||
("ResponseHTTP", "response_http"), | ||
("ResponseHTTP200", "response_http200"), | ||
("getHTTPResponseCode", "get_http_response_code"), | ||
("get200HTTPResponseCode", "get200_http_response_code"), | ||
("getHTTP200ResponseCode", "get_http200_response_code"), | ||
("12PolarBears", "12_polar_bears"), | ||
("11buzzingBees", "11buzzing_bees"), | ||
("TacocaT", "tacoca_t"), | ||
("fooBARbaz", "foo_ba_rbaz"), | ||
("foo_BAR_baz", "foo_bar_baz"), | ||
("Base_BASE", "base_base"), | ||
("Case_Case", "case_case"), | ||
("FACE_Face", "face_face"), | ||
) | ||
for camel, snake in test_strings: | ||
assert camel_to_snake(camel) == snake | ||
|
||
def test_camel_to_snake_dict(self): | ||
test_strings = { | ||
"camelCase": "camel_case", | ||
"PascalCase": "pascal_case", | ||
"camelCasePlace": "camel_case_place", | ||
"Pascal8Camel8Snake": "pascal8_camel8_snake", | ||
"HTTPResponseCode": "http_response_code", | ||
"ResponseHTTP": "response_http", | ||
"ResponseHTTP200": "response_http200", | ||
"getHTTPResponseCode": "get_http_response_code", | ||
"get200HTTPResponseCode": "get200_http_response_code", | ||
"getHTTP200ResponseCode": "get_http200_response_code", | ||
"12PolarBears": "12_polar_bears", | ||
"11buzzingBees": "11buzzing_bees", | ||
"TacocaT": "tacoca_t", | ||
"fooBARbaz": "foo_ba_rbaz", | ||
"foo_BAR_baz": "foo_bar_baz", | ||
"Base_BASE": "base_base", | ||
"Case_Case": "case_case", | ||
"FACE_Face": "face_face", | ||
} | ||
new_test = snake_case_keys(test_strings) | ||
for key, item in new_test.items(): | ||
assert key == item |
This file was deleted.
Oops, something went wrong.