Skip to content

Commit

Permalink
clean up test
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Nov 27, 2024
1 parent d575d59 commit a1d0a13
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions tests/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,24 +197,26 @@ def test_frozen_attrdict():
dct = FrozenAttrDict({"hello": "world", 1: 2})
assert isinstance(dct, UserDict)

# Test attribute-like operations
with pytest.raises(TypeError, match="does not support item assignment"):
dct.foo = "bar"

with pytest.raises(TypeError, match="does not support item assignment"):
dct.hello = "new"

with pytest.raises(TypeError, match="does not support item deletion"):
del dct.hello

# Test get value
assert dct["hello"] == "world"
assert dct.hello == "world"
assert dct["hello"] is dct.hello
assert dct["hello"] is dct.hello # identity check

# Test adding item
with pytest.raises(TypeError, match="add is disabled"):
dct["foo"] = "bar"
with pytest.raises(
TypeError, match="FrozenAttrDict does not support item assignment"
):
dct.foo = "bar"

# Test modifying existing item
with pytest.raises(
TypeError, match="FrozenAttrDict does not support item assignment"
):
dct.hello = "new"
with pytest.raises(TypeError, match="update is disabled"):
dct["hello"] = "new"

Expand All @@ -233,9 +235,6 @@ def test_frozen_attrdict():
with pytest.raises(TypeError, match="delete is disabled"):
del dct["hello"]

with pytest.raises(TypeError, match="does not support item deletion"):
del dct.hello

with pytest.raises(TypeError, match="delete is disabled"):
dct.clear()

Expand Down

0 comments on commit a1d0a13

Please sign in to comment.