MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_sync_signal

Function test_sync_signal

test/mitmproxy/utils/test_signals.py:9–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7
8
9def test_sync_signal() -> None:
10 m = mock.Mock()
11
12 s = SyncSignal(lambda event: None)
13 s.connect(m)
14 s.send("foo")
15
16 assert m.call_args_list == [mock.call("foo")]
17
18 class Foo:
19 called = None
20
21 def bound(self, event):
22 self.called = event
23
24 f = Foo()
25 s.connect(f.bound)
26 s.send(event="bar")
27 assert f.called == "bar"
28 assert m.call_args_list == [mock.call("foo"), mock.call(event="bar")]
29
30 s.disconnect(m)
31 s.send("baz")
32 assert f.called == "baz"
33 assert m.call_count == 2
34
35 def err(event):
36 raise RuntimeError
37
38 s.connect(err)
39 with pytest.raises(RuntimeError):
40 s.send(42)
41
42
43def test_signal_weakref() -> None:

Callers

nothing calls this directly

Calls 6

SyncSignalFunction · 0.90
FooClass · 0.70
connectMethod · 0.45
sendMethod · 0.45
callMethod · 0.45
disconnectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…