mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-12-02 12:01:17 +00:00
Testing using addon
This commit is contained in:
parent
167e01acdf
commit
5dcc3b4ff8
@ -1,5 +1,4 @@
|
|||||||
import typing
|
import typing
|
||||||
from unittest import mock
|
|
||||||
from mitmproxy import command
|
from mitmproxy import command
|
||||||
from mitmproxy import flow
|
from mitmproxy import flow
|
||||||
from mitmproxy import exceptions
|
from mitmproxy import exceptions
|
||||||
@ -310,16 +309,23 @@ class TDec:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TAttr:
|
||||||
|
def __getattr__(self, item):
|
||||||
|
raise IOError
|
||||||
|
|
||||||
|
|
||||||
|
class TCmds(TAttr):
|
||||||
|
def __init__(self):
|
||||||
|
self.TAttr = TAttr()
|
||||||
|
|
||||||
|
|
||||||
def test_collect_commands():
|
def test_collect_commands():
|
||||||
"""
|
"""
|
||||||
This tests for the error thrown by hasattr()
|
This tests for the error thrown by hasattr()
|
||||||
"""
|
"""
|
||||||
with mock.patch("mitmproxy.command.hasattr") as mock_hasattr:
|
|
||||||
mock_hasattr.return_value = False
|
|
||||||
with taddons.context() as tctx:
|
with taddons.context() as tctx:
|
||||||
mock_hasattr.side_effect = OSError
|
|
||||||
c = command.CommandManager(tctx.master)
|
c = command.CommandManager(tctx.master)
|
||||||
a = TDec()
|
a = TCmds()
|
||||||
c.collect_commands(a)
|
c.collect_commands(a)
|
||||||
assert "cmd1" not in c.commands
|
assert "cmd1" not in c.commands
|
||||||
assert "cmd2" not in c.commands
|
assert "cmd2" not in c.commands
|
||||||
|
Loading…
Reference in New Issue
Block a user