예제 #1
0
 def test_value_change(self):
     """ New attribute values should update dictionary keys & vice versa """
     x = CleverDict()
     x.life = 42
     x["life"] = 43
     assert x.life == 43
     assert x["life"] == 43
     x.life = 42
     assert x.life == 42
     assert x["life"] == 42
     x["1"] = 10
     assert x["1"] == 10
     assert x["_1"] == 10
     assert x._1 == 10
     x["_1"] = 11
     assert x["1"] == 11
     assert x["_1"] == 11
     assert x._1 == 11
     x._1 = 12
     assert x["1"] == 12
     assert x["_1"] == 12
     assert x._1 == 12
     # can't double assign
     with pytest.raises(KeyError):
         x["+1"] = 1
예제 #2
0
 def test_value_change(self):
     """ New attribute values should update dictionary keys & vice versa """
     x = CleverDict()
     x.life = 42
     x['life'] = 43
     assert x.life == 43
     assert x['life'] == 43
     x.life = 42
     assert x.life == 42
     assert x['life'] == 42