MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_saving

Function test_saving

test/mitmproxy/test_optmanager.py:310–346  ·  view source on GitHub ↗
(tmpdir)

Source from the content-addressed store, hash-verified

308
309
310def test_saving(tmpdir):
311 o = TD2()
312 o.three = "set"
313 dst = Path(tmpdir.join("conf"))
314 optmanager.save(o, dst, defaults=True)
315
316 o2 = TD2()
317 optmanager.load_paths(o2, dst)
318 o2.three = "foo"
319 optmanager.save(o2, dst, defaults=True)
320
321 optmanager.load_paths(o, dst)
322 assert o.three == "foo"
323
324 with open(dst, "a") as f:
325 f.write("foobar: '123'")
326 optmanager.load_paths(o, dst)
327 assert o.deferred == {"foobar": "123"}
328
329 with open(dst, "a") as f:
330 f.write("'''")
331 with pytest.raises(exceptions.OptionsError):
332 optmanager.load_paths(o, dst)
333
334 with open(dst, "wb") as f:
335 f.write(b"\x01\x02\x03")
336 with pytest.raises(exceptions.OptionsError):
337 optmanager.load_paths(o, dst)
338 with pytest.raises(exceptions.OptionsError):
339 optmanager.save(o, dst)
340
341 with open(dst, "wb") as f:
342 f.write(b"\xff\xff\xff")
343 with pytest.raises(exceptions.OptionsError):
344 optmanager.load_paths(o, dst)
345 with pytest.raises(exceptions.OptionsError):
346 optmanager.save(o, dst)
347
348
349def test_merge():

Callers

nothing calls this directly

Calls 5

TD2Class · 0.85
PathClass · 0.85
joinMethod · 0.45
saveMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…