Exemplo n.º 1
0
 def test_setdefault_on_missing_with_no_default_returns_none(self):
     # given
     p = PropertySet()
     # when
     value = p.setdefault("name")
     # then
     assert value is None
Exemplo n.º 2
0
 def test_setdefault_on_existing_returns_existing(self):
     # given
     p = PropertySet(name="Alice")
     # when
     value = p.setdefault("name", "Bob")
     # then
     assert value == "Alice"
Exemplo n.º 3
0
 def test_setdefault_on_missing_returns_default(self):
     # given
     p = PropertySet()
     # when
     value = p.setdefault("name", "Bob")
     # then
     assert value == "Bob"
Exemplo n.º 4
0
 def test_setdefault_on_missing_with_no_default_returns_none(self):
     # given
     p = PropertySet()
     # when
     value = p.setdefault("name")
     # then
     assert value is None
Exemplo n.º 5
0
 def test_setdefault_on_missing_with_no_default_does_not_add_key(self):
     # given
     p = PropertySet()
     # when
     p.setdefault("name")
     # then
     assert "name" not in p
Exemplo n.º 6
0
 def test_setdefault_on_missing_returns_default(self):
     # given
     p = PropertySet()
     # when
     value = p.setdefault("name", "Bob")
     # then
     assert value == "Bob"
Exemplo n.º 7
0
 def test_setdefault_on_existing_returns_existing(self):
     # given
     p = PropertySet(name="Alice")
     # when
     value = p.setdefault("name", "Bob")
     # then
     assert value == "Alice"
Exemplo n.º 8
0
 def test_update_with_key_value_list(self):
     # given
     p = PropertySet()
     # when
     p.update([("name", "Alice")])
     # then
     assert p["name"] == "Alice"
Exemplo n.º 9
0
 def test_update_with_dict(self):
     # given
     p = PropertySet()
     # when
     p.update({"name": "Alice"})
     # then
     assert p["name"] == "Alice"
Exemplo n.º 10
0
 def test_setdefault_on_missing_with_no_default_does_not_add_key(self):
     # given
     p = PropertySet()
     # when
     p.setdefault("name")
     # then
     assert "name" not in p
Exemplo n.º 11
0
 def test_deleting_sets_to_none(self):
     # given
     p = PropertySet(name="Alice")
     # when
     del p["name"]
     # then
     assert p["name"] == None
Exemplo n.º 12
0
 def test_setting_to_none_deletes(self):
     # given
     p = PropertySet(name="Alice")
     # when
     p["name"] = None
     # then
     assert "name" not in p
Exemplo n.º 13
0
 def test_missing_property_is_none(self):
     # when
     p = PropertySet()
     # then
     assert p["name"] is None
Exemplo n.º 14
0
 def test_none_is_not_stored(self):
     # when
     p = PropertySet(name=None)
     # then
     assert "name" not in p