Skip to content

Commit

Permalink
add tests for delete
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Nov 27, 2024
1 parent 984f828 commit 3c55c5c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,33 @@ def test_CaseInsensitiveDictUpper():
assert "G" in upper_dict
assert "non-existent" not in upper_dict

# Test `__delitem__`
del upper_dict["hi"]
assert "hi" not in upper_dict
assert "HI" not in upper_dict

# Test `del dct[key]`
del upper_dict["b"]
assert "b" not in upper_dict
assert "B" not in upper_dict

# Test `pop(key)`
popped_value = upper_dict.pop("c")
assert popped_value == 5
assert "c" not in upper_dict
assert "C" not in upper_dict

# Test `pop(key)` with default value (key exists)
popped_value = upper_dict.pop("d", "default")
assert popped_value == 6
assert "d" not in upper_dict
assert "D" not in upper_dict

# Test `pop(key)` with default value (key doesn't exist)
popped_value = upper_dict.pop("non-existent", "default")
assert popped_value == "default"
assert "non-existent" not in upper_dict


class TestTree:
def test_tree(self):
Expand Down

0 comments on commit 3c55c5c

Please sign in to comment.