Remove to_const function (#1212)

This commit is contained in:
Jonathan Kim 2020-06-25 03:21:40 +01:00 committed by GitHub
parent 4b70186031
commit a1fc3688aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 15 deletions

View File

@ -1,5 +1,4 @@
import re
from unidecode import unidecode
# Adapted from this response in Stackoverflow
@ -16,7 +15,3 @@ def to_camel_case(snake_str):
def to_snake_case(name):
s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", name)
return re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1).lower()
def to_const(string):
return re.sub(r"[\W|^]+", "_", unidecode(string)).upper()

View File

@ -1,5 +1,5 @@
# coding: utf-8
from ..str_converters import to_camel_case, to_const, to_snake_case
from ..str_converters import to_camel_case, to_snake_case
def test_snake_case():
@ -17,11 +17,3 @@ def test_camel_case():
assert to_camel_case("snakes_on_a__plane") == "snakesOnA_Plane"
assert to_camel_case("i_phone_hysteria") == "iPhoneHysteria"
assert to_camel_case("field_i18n") == "fieldI18n"
def test_to_const():
assert to_const('snakes $1. on a "#plane') == "SNAKES_1_ON_A_PLANE"
def test_to_const_unicode():
assert to_const("Skoða þetta unicode stöff") == "SKODA_THETTA_UNICODE_STOFF"

View File

@ -85,7 +85,6 @@ setup(
"graphql-core>=3.1.0b1,<4",
"graphql-relay>=3.0,<4",
"aniso8601>=8,<9",
"unidecode>=1.1.1,<2",
],
tests_require=tests_require,
extras_require={"test": tests_require, "dev": dev_requires},