@@ -2104,24 +2104,40 @@ class TestSymmetricEmptyValEquivalency(TestCase):
2104
2104
2105
2105
def test (self ):
2106
2106
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 )):
2108
2113
2109
- A = 'A' , 'ok '
2110
- B = 'B' , 'none '
2114
+ A = 'A' , 'A Label '
2115
+ B = None , 'B Label '
2111
2116
2112
2117
try :
2113
2118
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
2116
2120
self .fail (
2117
2121
"EnumChoiceField() raised value error with alternative"
2118
2122
"empty_value set."
2119
2123
)
2120
2124
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 )
2125
2141
2126
2142
class EmptyEqEnum2 (
2127
2143
TextChoices ,
0 commit comments