Skip to content

Commit 1e9548b

Browse files
committed
update null value tests to reflect string conversion 'none' -> None in enum_properties no longer works
1 parent 7ac0867 commit 1e9548b

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

django_enum/tests/tests.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,24 +2104,40 @@ class TestSymmetricEmptyValEquivalency(TestCase):
21042104

21052105
def test(self):
21062106

2107-
class EmptyEqEnum(TextChoices, s('prop', case_fold=True)):
2107+
# version 1.5.0 of enum_properties changed the default symmetricity
2108+
# of none values.
2109+
from enum_properties import VERSION
2110+
match_none = {} if VERSION < (1, 5, 0) else {'match_none': True}
2111+
2112+
class EmptyEqEnum(EnumProperties, s('label', case_fold=True)):
21082113

2109-
A = 'A', 'ok'
2110-
B = 'B', 'none'
2114+
A = 'A', 'A Label'
2115+
B = None, 'B Label'
21112116

21122117
try:
21132118
form_field = EnumChoiceField(enum=EmptyEqEnum)
2114-
self.assertTrue(None not in form_field.empty_values)
2115-
except Exception: # pragma: no cover
2119+
except Exception as err: # pragma: no cover
21162120
self.fail(
21172121
"EnumChoiceField() raised value error with alternative"
21182122
"empty_value set."
21192123
)
21202124

2121-
# version 1.5.0 of enum_properties changed the default symmetricity
2122-
# of none values.
2123-
from enum_properties import VERSION
2124-
match_none = {} if VERSION < (1, 5, 0) else {'match_none': True}
2125+
self.assertTrue(None not in form_field.empty_values)
2126+
2127+
class EmptyEqEnum(EnumProperties, s('label', case_fold=True), s('prop', match_none=True)):
2128+
2129+
A = 'A', 'A Label', 4
2130+
B = 'B', 'B Label', None
2131+
2132+
try:
2133+
form_field = EnumChoiceField(enum=EmptyEqEnum)
2134+
except Exception as err: # pragma: no cover
2135+
self.fail(
2136+
"EnumChoiceField() raised value error with alternative"
2137+
"empty_value set."
2138+
)
2139+
2140+
self.assertTrue(None not in form_field.empty_values)
21252141

21262142
class EmptyEqEnum2(
21272143
TextChoices,

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ importlib-metadata = [
6868
{ version = "<5.0", markers = "python_version <= '3.7'" },
6969
{ version = ">=5.0", markers = "python_version > '3.7'" },
7070
]
71+
ipdb = "^0.13.13"
7172

7273
[build-system]
7374
requires = ["poetry-core>=1.0.0"]

0 commit comments

Comments
 (0)