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

Method test_reporthook_8193_bytes

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

Source from the content-addressed store, hash-verified

722 self.assertEqual(report[1][2], 5)
723
724 def test_reporthook_8193_bytes(self):
725 # Test on 8193 byte file. Should call reporthook only 3 times (once
726 # when the "network connection" is established, once for the next 8192
727 # bytes, and once for the last byte).
728 report = []
729 def hooktester(block_count, block_read_size, file_size, _report=report):
730 _report.append((block_count, block_read_size, file_size))
731 srcFileName = self.createNewTempFile(b"x" * 8193)
732 urllib.request.urlretrieve(self.constructLocalFileUrl(srcFileName),
733 os_helper.TESTFN, hooktester)
734 self.assertEqual(len(report), 3)
735 self.assertEqual(report[0][2], 8193)
736 self.assertEqual(report[0][1], 8192)
737 self.assertEqual(report[1][1], 8192)
738 self.assertEqual(report[2][1], 8192)
739
740
741class urlretrieve_HttpTests(unittest.TestCase, FakeHTTPMixin):

Callers

nothing calls this directly

Calls 4

createNewTempFileMethod · 0.95
constructLocalFileUrlMethod · 0.95
urlretrieveMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected