Esempio n. 1
0
 def test_inequality(self):
     first = PropertySet({
         "name": "Alice",
         "age": 33,
         "colours": ["red", "purple"]
     })
     second = PropertySet({
         "name": "Bob",
         "age": 44,
         "colours": ["blue", "purple"]
     })
     assert first != second
Esempio n. 2
0
 def test_hashable(self):
     first = PropertySet({
         "name": "Alice",
         "age": 33,
         "colours": ["red", "purple"]
     })
     second = PropertySet({
         "name": "Bob",
         "age": 44,
         "colours": ["blue", "purple"]
     })
     collected = {first, second}
     assert len(collected) == 2
Esempio n. 3
0
 def test_byte_arrays_are_not_supported(self):
     try:
         PropertySet({"value": bytearray(b"hello, world")})
     except TypeError:
         assert True
     else:
         assert False
Esempio n. 4
0
 def test_integer_too_low(self):
     try:
         PropertySet({"value": -(2**64)})
     except ValueError:
         assert True
     else:
         assert False
Esempio n. 5
0
 def test_heterogenous_list(self):
     try:
         PropertySet({"value": [True, 2, u"three"]})
     except ValueError:
         assert True
     else:
         assert False
Esempio n. 6
0
 def test_integer_too_high(self):
     try:
         PropertySet({"value": 2**64})
     except ValueError:
         assert True
     else:
         assert False
Esempio n. 7
0
 def test_setdefault_without_default_with_non_existent(self):
     properties = PropertySet({"name": "Alice"})
     value = properties.setdefault("age")
     assert properties == {"name": "Alice", "age": None}
     assert value is None
Esempio n. 8
0
 def test_unicode_strings_are_supported(self):
     props = PropertySet({"value": u"hello, world"})
     assert props == {"value": u"hello, world"}
Esempio n. 9
0
 def test_integer_in_range(self):
     props = PropertySet({"value": 1})
     assert props == {"value": 1}
Esempio n. 10
0
 def test_getter(self):
     properties = PropertySet({"name": "Alice"})
     assert properties["name"] == "Alice"
Esempio n. 11
0
 def test_setdefault_without_default_with_non_existent(self):
     properties = PropertySet({"name": "Alice"})
     value = properties.setdefault("age")
     assert properties == {"name": "Alice", "age": None}
     assert value is None
Esempio n. 12
0
 def test_homogenous_list(self):
     props = PropertySet({"value": [1, 2, 3]})
     assert props == {"value": [1, 2, 3]}
Esempio n. 13
0
 def test_setdefault_without_default_with_existing(self):
     properties = PropertySet({"name": "Alice", "age": 33})
     value = properties.setdefault("age")
     assert properties == {"name": "Alice", "age": 33}
     assert value == 33
Esempio n. 14
0
 def test_setter_with_none_for_non_existent(self):
     properties = PropertySet({"name": "Alice"})
     properties["age"] = None
     assert properties == {"name": "Alice"}
Esempio n. 15
0
 def test_setter_with_none(self):
     properties = PropertySet({"name": "Alice", "age": 33})
     properties["age"] = None
     assert properties == {"name": "Alice"}
Esempio n. 16
0
 def test_setter(self):
     properties = PropertySet({"name": "Alice"})
     properties["age"] = 33
     assert properties == {"name": "Alice", "age": 33}
Esempio n. 17
0
 def test_getter_with_none(self):
     properties = PropertySet({"name": "Alice"})
     assert properties["age"] is None
Esempio n. 18
0
 def test_homogenous_list_of_strings(self):
     props = PropertySet({"value": [u"hello", b"world"]})
     assert props == {"value": [u"hello", u"world"]}
Esempio n. 19
0
 def test_setdefault_with_default_with_non_existent(self):
     properties = PropertySet({"name": "Alice"})
     value = properties.setdefault("age", 33)
     assert properties == {"name": "Alice", "age": 33}
     assert value == 33
Esempio n. 20
0
 def test_setdefault_without_default_with_existing(self):
     properties = PropertySet({"name": "Alice", "age": 33})
     value = properties.setdefault("age")
     assert properties == {"name": "Alice", "age": 33}
     assert value == 33
Esempio n. 21
0
 def test_deleter(self):
     properties = PropertySet({"name": "Alice", "age": 33})
     del properties["age"]
     assert properties == {"name": "Alice"}
Esempio n. 22
0
 def test_setdefault_with_default_with_non_existent(self):
     properties = PropertySet({"name": "Alice"})
     value = properties.setdefault("age", 33)
     assert properties == {"name": "Alice", "age": 33}
     assert value == 33
Esempio n. 23
0
 def test_boolean(self):
     props = PropertySet({"value": True})
     assert props == {"value": True}