summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPhil Jones <philip.graham.jones@googlemail.com>2023-01-23 23:00:32 +0000
committerGitHub <noreply@github.com>2023-01-24 00:00:32 +0100
commitd06b2416ea43c535b907b7d0a2b72fff3b2f3a0f (patch)
tree566da903678855496ab9d691f229edc2bf89c917 /tests
parent9c2f289f024e7aac20bf3dbdebfc4ec279df3458 (diff)
downloadblinker-d06b2416ea43c535b907b7d0a2b72fff3b2f3a0f.tar.gz
Added `muted` context manager for temproary switching signal off (#84)
This is useful whilst testing to remove a signal's affects. Co-authored-by: Michael Elovskikh <wronglink@yandex-team.ru>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_signals.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_signals.py b/tests/test_signals.py
index 0879b5c..e79ff7f 100644
--- a/tests/test_signals.py
+++ b/tests/test_signals.py
@@ -512,6 +512,23 @@ def test_named_blinker():
assert "squiznart" in repr(sig)
+def test_mute_signal():
+ sentinel = []
+
+ def received(sender):
+ sentinel.append(sender)
+
+ sig = blinker.Signal()
+ sig.connect(received)
+
+ sig.send(123)
+ assert 123 in sentinel
+
+ with sig.muted():
+ sig.send(456)
+ assert 456 not in sentinel
+
+
def values_are_empty_sets_(dictionary):
for val in dictionary.values():
assert val == set()