def test_len(self): d = DotDict({"chris": 10, "attr": "string", "other": lambda x: {}}) assert len(d) == 3 a = DotDict() assert len(a) == 0 a.update(new=4) assert len(a) == 1 del d["chris"] assert len(d) == 2
def test_update_with_mutable_mapping(self, mutable_mapping): d = DotDict({"chris": 10, "attr": "string", "other": lambda x: {}}) assert "another" not in d d.update(mutable_mapping) assert "another" in d
def test_update_with_kwargs(self): d = DotDict(chris=10, attr="string", other=lambda x: {}) assert "another" not in d d.update(another=500) assert "another" in d assert d["another"] == 500
def test_protect_critical_keys_active(): x = DotDict() with pytest.raises(ValueError): x.update = 1