MCPcopy Create free account
hub / github.com/mitmproxy/mitmproxy / test_options

Function test_options

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

Source from the content-addressed store, hash-verified

90
91
92def test_options():
93 o = TO()
94 assert o.keys() == {"bool", "one", "two", "required_int"}
95
96 assert o.one is None
97 assert o.two == 2
98 o.one = 1
99 assert o.one == 1
100
101 with pytest.raises(TypeError):
102 TO(nonexistent="value")
103 with pytest.raises(Exception, match="Unknown options"):
104 o.nonexistent = "value"
105 with pytest.raises(Exception, match="Unknown options"):
106 o.update(nonexistent="value")
107 assert o.update_known(nonexistent="value") == {"nonexistent": "value"}
108
109 rec = []
110
111 def sub(updated):
112 rec.append(copy.copy(o))
113
114 o.changed.connect(sub)
115
116 o.one = 90
117 assert len(rec) == 1
118 assert rec[-1].one == 90
119
120 o.update(one=3)
121 assert len(rec) == 2
122 assert rec[-1].one == 3
123
124
125def test_setter():

Callers

nothing calls this directly

Calls 5

update_knownMethod · 0.80
TOClass · 0.70
keysMethod · 0.45
updateMethod · 0.45
connectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…