Skip to content

Commit e797d50

Browse files
committed
update tests to hit all cov
1 parent b45614c commit e797d50

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

django_enum/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def enum(self, enum):
9898
empty for empty in self.empty_values
9999
if empty != enum_val
100100
]
101-
if empty == self.empty_value:
101+
if enum_val == self.empty_value:
102102
if self.empty_values:
103103
self.empty_value = self.empty_values[0]
104104
else:

django_enum/tests/tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,6 +2128,7 @@ class EmptyEqEnum(EnumProperties, s('label', case_fold=True), s('prop', match_no
21282128

21292129
A = 'A', 'A Label', 4
21302130
B = 'B', 'B Label', None
2131+
C = 'C', 'C Label', ''
21312132

21322133
try:
21332134
form_field = EnumChoiceField(enum=EmptyEqEnum)
@@ -2137,7 +2138,10 @@ class EmptyEqEnum(EnumProperties, s('label', case_fold=True), s('prop', match_no
21372138
"empty_value set."
21382139
)
21392140

2141+
# this is pathological
21402142
self.assertTrue(None not in form_field.empty_values)
2143+
self.assertTrue('' not in form_field.empty_values)
2144+
self.assertTrue(form_field.empty_value == form_field.empty_values[0])
21412145

21422146
class EmptyEqEnum2(
21432147
TextChoices,

0 commit comments

Comments
 (0)