Skip to content

Commit 26f7064

Browse files
committed
[refs #263] Add test for tuples in TextChoice
Why: - Test that the fields label and value are not marked as missing This change addresses the need by: - Adding a test to ensure that pylint does not mark these as errors
1 parent ce6c3e9 commit 26f7064

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
Test that django TextChoices does not raise a warning due to .label and .value methods
3+
"""
4+
# pylint: disable=missing-docstring,too-few-public-methods
5+
6+
from django.db import models
7+
8+
9+
class SomeTextChoices(models.TextChoices):
10+
CHOICE_A = ("choice_a", "Choice A")
11+
CHOICE_B = ("choice_b", "Choice B")
12+
CHOICE_C = ("choice_c", "Choice C")
13+
14+
15+
class SomeClass():
16+
choice_values = [
17+
SomeTextChoices.CHOICE_A.value,
18+
SomeTextChoices.CHOICE_B.value,
19+
]
20+
choice_labels = [
21+
SomeTextChoices.CHOICE_B.label,
22+
SomeTextChoices.CHOICE_C.label,
23+
]

0 commit comments

Comments
 (0)