diff --git a/unittests/test_property.py b/unittests/test_property.py index 42e7d2d35d980b2f86d333ff1a72d38ba21fa9c4..84f89b5a959192d7831e1bb3eab3a441912afe7e 100644 --- a/unittests/test_property.py +++ b/unittests/test_property.py @@ -146,13 +146,15 @@ def test_remove_value_from_property(): ("testListProp2", ["a", "b", "a"], db.LIST(db.TEXT)), ("testScalarProp1", "bla", db.TEXT), ("testScalarProp2", False, db.BOOLEAN), - ("testEmptyProp", None, db.REFERENCE) + ("testEmptyProp", None, db.REFERENCE), + ("testNoneListProp", [None, None], db.LIST(db.REFERENCE)), ] for name, value, dtype in names_values_dtypes: rec.add_property(name=name, value=value, datatype=dtype) # property doesn't exist, so do nothing - rec.remove_value_from_property("nonexisting", "some_value") + returned = rec.remove_value_from_property("nonexisting", "some_value") + assert returned is rec for name, value, dtype in names_values_dtypes: assert rec.get_property(name).value == value assert rec.get_property(name).datatype == dtype @@ -162,7 +164,8 @@ def test_remove_value_from_property(): assert rec.get_property("testListProp1").value == [1, 2, 3] assert rec.get_property("testListProp1").datatype == db.LIST(db.INTEGER) - rec.remove_value_from_property("testScalarProp2", True) + returned = rec.remove_value_from_property("testScalarProp2", True) + assert returned is rec assert rec.get_property("testScalarProp2").value is False assert rec.get_property("testScalarProp2").datatype == db.BOOLEAN @@ -211,3 +214,9 @@ def test_remove_value_from_property(): assert rec.get_property("testEmptyProp") is not None assert rec.get_property("testEmptyProp").value is None assert rec.get_property("testEmptyProp").datatype == db.REFERENCE + + # Remove `None` from list `[None, None]` + rec.remove_value_from_property("testNoneListProp", None, remove_if_empty_afterwards=True) + assert rec.get_property("testNoneListProp") is not None + assert rec.get_property("testNoneListProp").value == [None] + assert rec.get_property("testNoneListProp").datatype == db.LIST(db.REFERENCE)