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

Method test_freshen_update

testUpdateHostsFile.py:313–340  ·  view source on GitHub ↗
(self, _)

Source from the content-addressed store, hash-verified

311
312 @mock.patch("updateHostsFile.query_yes_no", return_value=True)
313 def test_freshen_update(self, _):
314 hostsfile = os.path.join(self.test_dir, "hosts")
315 hosts_data = "This data should not be overwritten"
316
317 with self.mock_property("updateHostsFile.BASEDIR_PATH"):
318 updateHostsFile.BASEDIR_PATH = self.test_dir
319
320 with open(hostsfile, "w") as f:
321 f.write(hosts_data)
322
323 dir_count = self.dir_count
324
325 for updateauto in (False, True):
326 updatesources = prompt_for_update(
327 freshen=True, updateauto=updateauto
328 )
329 self.assertTrue(updatesources)
330
331 output = sys.stdout.getvalue()
332 self.assertEqual(output, "")
333
334 sys.stdout = StringIO()
335
336 self.assertEqual(self.dir_count, dir_count)
337
338 with open(hostsfile, "r") as f:
339 contents = f.read()
340 self.assertEqual(contents, hosts_data)
341
342 def tearDown(self):
343 BaseStdout.tearDown(self)

Callers

nothing calls this directly

Calls 2

prompt_for_updateFunction · 0.90
mock_propertyMethod · 0.80

Tested by

no test coverage detected