MCPcopy Index your code
hub / github.com/python/cpython / test_reporthook

Method test_reporthook

Lib/test/test_urllib.py:685–697  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

683 self.assertEqual(self.text, text)
684
685 def test_reporthook(self):
686 # Make sure that the reporthook works.
687 def hooktester(block_count, block_read_size, file_size, count_holder=[0]):
688 self.assertIsInstance(block_count, int)
689 self.assertIsInstance(block_read_size, int)
690 self.assertIsInstance(file_size, int)
691 self.assertEqual(block_count, count_holder[0])
692 count_holder[0] = count_holder[0] + 1
693 second_temp = "%s.2" % os_helper.TESTFN
694 self.registerFileForCleanUp(second_temp)
695 urllib.request.urlretrieve(
696 self.constructLocalFileUrl(os_helper.TESTFN),
697 second_temp, hooktester)
698
699 def test_reporthook_0_bytes(self):
700 # Test on zero length file. Should call reporthook only 1 time.

Callers

nothing calls this directly

Calls 3

constructLocalFileUrlMethod · 0.95
urlretrieveMethod · 0.80

Tested by

no test coverage detected