@@ -166,6 +166,14 @@ def test_condition_when_complex():
166166 ({"tags__contains" : "go" }, {"tags" : ["python" , "java" ]}, False ),
167167 ({"text__contains" : "hello" }, {"text" : "say hello world" }, True ),
168168 ({"text__contains" : "goodbye" }, {"text" : "say hello world" }, False ),
169+ # __is (identity)
170+ ({"value__is" : None }, {"value" : None }, True ),
171+ ({"value__is" : None }, {"value" : 0 }, False ),
172+ ({"value__is" : True }, {"value" : True }, True ),
173+ ({"value__is" : True }, {"value" : 1 }, False ),
174+ # __isnot (not identity)
175+ ({"value__isnot" : None }, {"value" : "hello" }, True ),
176+ ({"value__isnot" : None }, {"value" : None }, False ),
169177 ],
170178 ids = [
171179 "eq-match" ,
@@ -193,6 +201,12 @@ def test_condition_when_complex():
193201 "contains-list-no-match" ,
194202 "contains-str-match" ,
195203 "contains-str-no-match" ,
204+ "is-none-match" ,
205+ "is-none-no-match" ,
206+ "is-true-match" ,
207+ "is-true-not-identical" ,
208+ "isnot-not-none" ,
209+ "isnot-is-none" ,
196210 ],
197211)
198212def test_condition_when_operators (kwargs , state_dict , expected ):
@@ -226,11 +240,13 @@ def test_condition_when_operators_reads(kwargs, expected_reads):
226240 ({"status__in" : ["a" , "b" ]}, "status in ['a', 'b']" ),
227241 ({"status__notin" : ["x" ]}, "status not in ['x']" ),
228242 ({"tags__contains" : "py" }, "tags contains 'py'" ),
243+ ({"value__is" : None }, "value is None" ),
244+ ({"value__isnot" : None }, "value is not None" ),
229245 # plain equality still uses old format
230246 ({"foo" : "bar" }, "foo=bar" ),
231247 ({"foo" : "bar" , "baz" : "qux" }, "baz=qux, foo=bar" ),
232248 ],
233- ids = ["gte" , "lt" , "ne" , "in" , "notin" , "contains" , "plain-eq" , "plain-multi" ],
249+ ids = ["gte" , "lt" , "ne" , "in" , "notin" , "contains" , "is" , "isnot" , " plain-eq" , "plain-multi" ],
234250)
235251def test_condition_when_operators_name (kwargs , expected_name ):
236252 cond = Condition .when (** kwargs )
0 commit comments