mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-25 18:03:50 +00:00
Deprecate Flow.unload_script in favor of Flow.unload_scripts
In the presence of arguments, unloading a single script is clumsy and less useful.
This commit is contained in:
parent
4f69eef8f3
commit
069aca1df4
@ -1394,9 +1394,10 @@ class FlowMaster(controller.Master):
|
||||
"""
|
||||
pass
|
||||
|
||||
def unload_script(self, script):
|
||||
script.unload()
|
||||
self.scripts.remove(script)
|
||||
def unload_scripts(self):
|
||||
for script in self.scripts[:]:
|
||||
script.unload()
|
||||
self.scripts.remove(script)
|
||||
|
||||
def load_script(self, command):
|
||||
"""
|
||||
@ -1627,8 +1628,7 @@ class FlowMaster(controller.Master):
|
||||
return f
|
||||
|
||||
def shutdown(self):
|
||||
for script in self.scripts:
|
||||
self.unload_script(script)
|
||||
self.unload_scripts()
|
||||
controller.Master.shutdown(self)
|
||||
if self.stream:
|
||||
for i in self.state._flow_list:
|
||||
|
@ -565,8 +565,7 @@ class TestFlowMaster:
|
||||
fm = flow.FlowMaster(None, s)
|
||||
assert not fm.load_script(tutils.test_data.path("scripts/a.py"))
|
||||
assert not fm.load_script(tutils.test_data.path("scripts/a.py"))
|
||||
assert not fm.unload_script(fm.scripts[0])
|
||||
assert not fm.unload_script(fm.scripts[0])
|
||||
assert not fm.unload_scripts()
|
||||
assert fm.load_script("nonexistent")
|
||||
assert "ValueError" in fm.load_script(tutils.test_data.path("scripts/starterr.py"))
|
||||
assert len(fm.scripts) == 0
|
||||
@ -613,9 +612,13 @@ class TestFlowMaster:
|
||||
fm.handle_clientdisconnect(dc)
|
||||
assert fm.scripts[0].ns["log"][-1] == "clientdisconnect"
|
||||
assert fm.scripts[1].ns["log"][-1] == "clientdisconnect"
|
||||
|
||||
|
||||
#unload first script
|
||||
fm.unload_script(fm.scripts[0])
|
||||
assert len(fm.scripts) == 1
|
||||
fm.unload_scripts()
|
||||
assert len(fm.scripts) == 0
|
||||
|
||||
assert not fm.load_script(tutils.test_data.path("scripts/all.py"))
|
||||
err = flow.Error(f.request, "msg")
|
||||
err.reply = controller.DummyReply()
|
||||
fm.handle_error(err)
|
||||
|
Loading…
Reference in New Issue
Block a user