Ejemplo n.º 1
0
 def test_float(self):
     props = PropertyDict({"value": 3.141})
     assert props == {"value": 3.141}
Ejemplo n.º 2
0
 def test_unicode_strings_are_supported(self):
     props = PropertyDict({"value": u"hello, world"})
     assert props == {"value": u"hello, world"}
Ejemplo n.º 3
0
 def test_integer_too_high(self):
     with self.assertRaises(ValueError):
         PropertyDict({"value": 2**64})
Ejemplo n.º 4
0
 def test_integer_too_low(self):
     with self.assertRaises(ValueError):
         PropertyDict({"value": -(2**64)})
Ejemplo n.º 5
0
 def test_getter_with_none(self):
     properties = PropertyDict({"name": "Alice"})
     assert properties["age"] is None
Ejemplo n.º 6
0
 def test_integer_in_range(self):
     props = PropertyDict({"value": 1})
     assert props == {"value": 1}
Ejemplo n.º 7
0
 def test_setdefault_with_default_with_non_existent(self):
     properties = PropertyDict({"name": "Alice"})
     value = properties.setdefault("age", 33)
     assert properties == {"name": "Alice", "age": 33}
     assert value == 33
Ejemplo n.º 8
0
 def test_homogenous_list_of_strings(self):
     props = PropertyDict({"value": [u"hello", b"world"]})
     assert props == {"value": [u"hello", u"world"]}
Ejemplo n.º 9
0
 def test_setdefault_without_default_with_existing(self):
     properties = PropertyDict({"name": "Alice", "age": 33})
     value = properties.setdefault("age")
     assert properties == {"name": "Alice", "age": 33}
     assert value == 33
Ejemplo n.º 10
0
 def test_setdefault_without_default_with_non_existent(self):
     properties = PropertyDict({"name": "Alice"})
     value = properties.setdefault("age")
     assert properties == {"name": "Alice"}
     assert value is None
Ejemplo n.º 11
0
 def test_setter_with_none_for_non_existent(self):
     properties = PropertyDict({"name": "Alice"})
     properties["age"] = None
     assert properties == {"name": "Alice"}
Ejemplo n.º 12
0
 def test_setter_with_none(self):
     properties = PropertyDict({"name": "Alice", "age": 33})
     properties["age"] = None
     assert properties == {"name": "Alice"}
Ejemplo n.º 13
0
 def test_setter(self):
     properties = PropertyDict({"name": "Alice"})
     properties["age"] = 33
     assert properties == {"name": "Alice", "age": 33}
Ejemplo n.º 14
0
 def test_byte_arrays_are_not_supported(self):
     with self.assertRaises(TypeError):
         PropertyDict({"value": bytearray(b"hello, world")})
Ejemplo n.º 15
0
 def test_deleter(self):
     properties = PropertyDict({"name": "Alice", "age": 33})
     del properties["age"]
     assert properties == {"name": "Alice"}
Ejemplo n.º 16
0
 def test_homogenous_list(self):
     props = PropertyDict({"value": [1, 2, 3]})
     assert props == {"value": [1, 2, 3]}
Ejemplo n.º 17
0
 def test_boolean(self):
     props = PropertyDict({"value": True})
     assert props == {"value": True}
Ejemplo n.º 18
0
 def test_heterogenous_list(self):
     with self.assertRaises(TypeError):
         PropertyDict({"value": [True, 2, u"three"]})
Ejemplo n.º 19
0
 def test_getter(self):
     properties = PropertyDict({"name": "Alice"})
     assert properties["name"] == "Alice"