Ejemplo n.º 1
0
 def test_deleter_where_non_existent(self):
     container = PropertyContainer(name="Alice")
     try:
         del container["age"]
     except KeyError:
         assert True
     else:
         assert False
Ejemplo n.º 2
0
 def test_keys(self):
     container = PropertyContainer(name="Alice", age=33)
     assert container.keys() == {"name", "age"}
Ejemplo n.º 3
0
 def test_iteration(self):
     container = PropertyContainer(name="Alice", age=33)
     assert set(container) == {"name", "age"}
Ejemplo n.º 4
0
 def test_contains(self):
     container = PropertyContainer(name="Alice", age=33)
     assert "name" in container
Ejemplo n.º 5
0
 def test_values(self):
     container = PropertyContainer(name="Alice", age=33)
     assert set(container.values()) == {'Alice', 33}
Ejemplo n.º 6
0
 def test_setdefault_where_missing(self):
     container = PropertyContainer(name="Alice")
     assert container.setdefault("age", 44) == 44
Ejemplo n.º 7
0
 def test_get_method_with_default(self):
     container = PropertyContainer(name="Alice")
     assert container.get("age", 33) == 33
Ejemplo n.º 8
0
 def test_clear(self):
     container = PropertyContainer(name="Alice", age=33)
     container.clear()
     assert len(container) == 0
Ejemplo n.º 9
0
 def test_get_method_with_default(self):
     container = PropertyContainer(name="Alice")
     assert container.get("age", 33) == 33
Ejemplo n.º 10
0
 def test_get_method(self):
     container = PropertyContainer(name="Alice", age=33)
     assert container.get("age") == 33
Ejemplo n.º 11
0
 def test_getter_where_non_existent(self):
     container = PropertyContainer(name="Alice")
     assert container["age"] is None
Ejemplo n.º 12
0
 def test_getter_where_exists(self):
     container = PropertyContainer(name="Alice", age=33)
     assert container["age"] == 33
Ejemplo n.º 13
0
 def test_clear(self):
     container = PropertyContainer(name="Alice", age=33)
     container.clear()
     assert len(container) == 0
Ejemplo n.º 14
0
 def test_not_contains(self):
     container = PropertyContainer(name="Alice")
     assert "age" not in container
Ejemplo n.º 15
0
 def test_values(self):
     container = PropertyContainer(name="Alice", age=33)
     assert set(container.values()) == {'Alice', 33}
Ejemplo n.º 16
0
 def test_update(self):
     container = PropertyContainer(name="Alice")
     container.update({"name": "Alice", "age": 33})
     assert dict(container) == {"name": "Alice", "age": 33}
Ejemplo n.º 17
0
 def test_setter_where_non_existent(self):
     container = PropertyContainer(name="Alice")
     container["age"] = 34
     assert dict(container) == {"name": "Alice", "age": 34}
Ejemplo n.º 18
0
 def test_get_method(self):
     container = PropertyContainer(name="Alice", age=33)
     assert container.get("age") == 33
Ejemplo n.º 19
0
 def test_setdefault_where_exists(self):
     container = PropertyContainer(name="Alice", age=33)
     assert container.setdefault("age", 44) == 33
Ejemplo n.º 20
0
 def test_setdefault_where_exists(self):
     container = PropertyContainer(name="Alice", age=33)
     assert container.setdefault("age", 44) == 33
Ejemplo n.º 21
0
 def test_setdefault_where_missing(self):
     container = PropertyContainer(name="Alice")
     assert container.setdefault("age", 44) == 44
Ejemplo n.º 22
0
 def test_keys(self):
     container = PropertyContainer(name="Alice", age=33)
     assert container.keys() == {"name", "age"}
Ejemplo n.º 23
0
 def test_deleter_where_exists(self):
     container = PropertyContainer(name="Alice", age=33)
     del container["age"]
     assert dict(container) == {"name": "Alice"}
Ejemplo n.º 24
0
 def test_update(self):
     container = PropertyContainer(name="Alice")
     container.update({"name": "Alice", "age": 33})
     assert dict(container) == {"name": "Alice", "age": 33}
Ejemplo n.º 25
0
 def test_length(self):
     container = PropertyContainer(name="Alice", age=33)
     assert len(container) == 2