mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 04:34:13 +03:00
chore: default enum description to "An enumeration." (#1502)
* Default enum description to "An enumeration." default to this string, which is used in many tests, is causing * Use the docstring descriptions of enums when they are present * Added tests * chore: add missing newline * Fix new line --------- Co-authored-by: Erik Wrede <erikwrede@users.noreply.github.com>
This commit is contained in:
parent
57cbef6666
commit
8ede21e063
|
@ -63,7 +63,7 @@ class EnumMeta(SubclassWithMeta_Meta):
|
|||
cls, enum, name=None, description=None, deprecation_reason=None
|
||||
): # noqa: N805
|
||||
name = name or enum.__name__
|
||||
description = description or enum.__doc__
|
||||
description = description or enum.__doc__ or "An enumeration."
|
||||
meta_dict = {
|
||||
"enum": enum,
|
||||
"description": description,
|
||||
|
|
|
@ -65,6 +65,21 @@ def test_enum_from_builtin_enum():
|
|||
assert RGB.BLUE
|
||||
|
||||
|
||||
def test_enum_custom_description_in_constructor():
|
||||
description = "An enumeration, but with a custom description"
|
||||
RGB = Enum(
|
||||
"RGB",
|
||||
"RED,GREEN,BLUE",
|
||||
description=description,
|
||||
)
|
||||
assert RGB._meta.description == description
|
||||
|
||||
|
||||
def test_enum_from_python3_enum_uses_default_builtin_doc():
|
||||
RGB = Enum("RGB", "RED,GREEN,BLUE")
|
||||
assert RGB._meta.description == "An enumeration."
|
||||
|
||||
|
||||
def test_enum_from_builtin_enum_accepts_lambda_description():
|
||||
def custom_description(value):
|
||||
if not value:
|
||||
|
|
Loading…
Reference in New Issue
Block a user