Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ababic committed Apr 20, 2023
1 parent 5c612c4 commit a81e5c3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tests/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def run(self):
assert test_local.counter == 6


def test_local_del_swallows_type_error(monkeypatch):
def test_local_clear_swallows_type_error(monkeypatch):
test_local = Local()

blow_up_calls = 0
Expand All @@ -319,6 +319,22 @@ def blow_up(self):

monkeypatch.setattr("weakref.WeakSet.__iter__", blow_up)

test_local.__del__()
test_local.clear()

assert blow_up_calls == 1


def test_local_clears_on_deletion(monkeypatch):
test_local = Local()

clear_call_count = 0

def clear_patched(self):
nonlocal clear_call_count
clear_call_count += 1

monkeypatch.setattr(test_local.clear, clear_patched)

del test_local

assert clear_call_count == 1

0 comments on commit a81e5c3

Please sign in to comment.