MCPcopy Create free account
hub / github.com/EasyIME/PIME / test_mock_patch

Method test_mock_patch

python/python3/tornado/test/options_test.py:176–195  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

174 self.assertEqual({}, options.group_dict("nonexistent"))
175
176 def test_mock_patch(self):
177 # ensure that our setattr hooks don't interfere with mock.patch
178 options = OptionParser()
179 options.define("foo", default=1)
180 options.parse_command_line(["main.py", "--foo=2"])
181 self.assertEqual(options.foo, 2)
182
183 with mock.patch.object(options.mockable(), "foo", 3):
184 self.assertEqual(options.foo, 3)
185 self.assertEqual(options.foo, 2)
186
187 # Try nested patches mixed with explicit sets
188 with mock.patch.object(options.mockable(), "foo", 4):
189 self.assertEqual(options.foo, 4)
190 options.foo = 5
191 self.assertEqual(options.foo, 5)
192 with mock.patch.object(options.mockable(), "foo", 6):
193 self.assertEqual(options.foo, 6)
194 self.assertEqual(options.foo, 5)
195 self.assertEqual(options.foo, 2)
196
197 def _define_options(self):
198 options = OptionParser()

Callers

nothing calls this directly

Calls 4

defineMethod · 0.95
parse_command_lineMethod · 0.95
mockableMethod · 0.95
OptionParserClass · 0.90

Tested by

no test coverage detected