MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_rollback

Function test_rollback

test/mitmproxy/test_optmanager.py:199–240  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

197
198
199def test_rollback():
200 o = TO()
201
202 rec = []
203
204 def sub(updated):
205 rec.append(copy.copy(o))
206
207 recerr = []
208
209 def errsub(**kwargs):
210 recerr.append(kwargs)
211
212 def err(updated):
213 if o.one == 10:
214 raise exceptions.OptionsError()
215 if o.bool is True:
216 raise exceptions.OptionsError()
217
218 o.changed.connect(sub)
219 o.changed.connect(err)
220 o.errored.connect(errsub)
221
222 assert o.one is None
223 with pytest.raises(exceptions.OptionsError):
224 o.one = 10
225 assert o.one is None
226 with pytest.raises(exceptions.OptionsError):
227 o.bool = True
228 assert o.bool is False
229 assert isinstance(recerr[0]["exc"], exceptions.OptionsError)
230 assert o.one is None
231 assert o.bool is False
232 assert len(rec) == 4
233 assert rec[0].one == 10
234 assert rec[1].one is None
235 assert rec[2].bool is True
236 assert rec[3].bool is False
237
238 with pytest.raises(exceptions.OptionsError):
239 with o.rollback({"one"}, reraise=True):
240 raise exceptions.OptionsError()
241
242
243def test_simple():

Callers

nothing calls this directly

Calls 3

rollbackMethod · 0.80
TOClass · 0.70
connectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…