MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_simple

Function test_simple

test/mitmproxy/test_addonmanager.py:177–215  ·  view source on GitHub ↗
(caplog)

Source from the content-addressed store, hash-verified

175
176
177async def test_simple(caplog):
178 with taddons.context(loadcore=False) as tctx:
179 a = tctx.master.addons
180
181 assert len(a) == 0
182 a.add(TAddon("one"))
183 assert a.get("one")
184 assert not a.get("two")
185 assert len(a) == 1
186 a.clear()
187 assert len(a) == 0
188 assert not a.chain
189
190 with taddons.context(loadcore=False) as tctx:
191 a.add(TAddon("one"))
192
193 a.trigger("nonexistent")
194 assert "AssertionError" in caplog.text
195
196 f = tflow.tflow()
197 a.trigger(hooks.RunningHook())
198 a.trigger(HttpResponseHook(f))
199 assert "not callable" in caplog.text
200 caplog.clear()
201
202 caplog.clear()
203 a.get("one").response = addons
204 a.trigger(HttpResponseHook(f))
205 assert "not callable" not in caplog.text
206
207 a.remove(a.get("one"))
208 assert not a.get("one")
209
210 ta = TAddon("one")
211 a.add(ta)
212 a.trigger(hooks.RunningHook())
213 assert ta.running_called
214
215 assert ta in a
216
217
218async def test_load_option():

Callers

nothing calls this directly

Calls 8

HttpResponseHookClass · 0.90
contextMethod · 0.80
triggerMethod · 0.80
TAddonClass · 0.70
addMethod · 0.45
getMethod · 0.45
clearMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…