From 0d3e2c6adff0479c42dc28880cd0258d32958fc2 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 23 Mar 2017 11:48:36 +1300 Subject: optmanager: make serialization and loading more robust Also handle errors in console options manager. --- test/mitmproxy/test_optmanager.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') diff --git a/test/mitmproxy/test_optmanager.py b/test/mitmproxy/test_optmanager.py index 01636640..31b6e52b 100644 --- a/test/mitmproxy/test_optmanager.py +++ b/test/mitmproxy/test_optmanager.py @@ -296,6 +296,20 @@ def test_saving(tmpdir): with pytest.raises(exceptions.OptionsError): optmanager.load_paths(o, dst) + with open(dst, 'wb') as f: + f.write(b"\x01\x02\x03") + with pytest.raises(exceptions.OptionsError): + optmanager.load_paths(o, dst) + with pytest.raises(exceptions.OptionsError): + optmanager.save(o, dst) + + with open(dst, 'wb') as f: + f.write(b"\xff\xff\xff") + with pytest.raises(exceptions.OptionsError): + optmanager.load_paths(o, dst) + with pytest.raises(exceptions.OptionsError): + optmanager.save(o, dst) + def test_merge(): m = TM() -- cgit v1.2.3