MCPcopy
hub / github.com/StevenBlack/hosts / test_no_freshen_fail_new_file

Method test_no_freshen_fail_new_file

testUpdateHostsFile.py:267–282  ·  view source on GitHub ↗
(self, mock_open)

Source from the content-addressed store, hash-verified

265
266 @mock.patch("builtins.open")
267 def test_no_freshen_fail_new_file(self, mock_open):
268 for exc in (IOError, OSError):
269 mock_open.side_effect = exc("failed open")
270
271 with self.mock_property("updateHostsFile.BASEDIR_PATH"):
272 updateHostsFile.BASEDIR_PATH = self.test_dir
273 prompt_for_update(freshen=False, updateauto=False)
274
275 output = sys.stdout.getvalue()
276 expected = (
277 "ERROR: No 'hosts' file in the folder. "
278 "Try creating one manually."
279 )
280 self.assertIn(expected, output)
281
282 sys.stdout = StringIO()
283
284 @mock.patch("updateHostsFile.query_yes_no", return_value=False)
285 def test_freshen_no_update(self, _):

Callers

nothing calls this directly

Calls 2

prompt_for_updateFunction · 0.90
mock_propertyMethod · 0.80

Tested by

no test coverage detected