def start(self, request, monkeypatch):
_env_list = self.env
_setup_dict = self.setup_dict
# first method for monkeypatching
def _setup(self, x):
_s = copy.deepcopy(_setup_dict)
return _s
# second method for monkeypatching
def _conf(self, x):
_e = copy.deepcopy(_env_list)
return _e
# monkeypatching methods _get_conf and _get_setup
monkeypatch.setattr(common3.Environment, "_get_conf", _conf)
monkeypatch.setattr(common3.Environment, "_get_setup", _setup)
# define environment with fake class
# mock Tkinter so we don't need Ixia installed
# I only know how to do this with mock, if monkeypatch can do this we should use that
with patch.dict('sys.modules', {'Tkinter': MagicMock()}):
env = common3.Environment(FakeOpts())
return env
# fake class for options
评论列表
文章目录