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

Method setUp

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

Source from the content-addressed store, hash-verified

603 """Test urllib.urlretrieve() on local files"""
604
605 def setUp(self):
606 # clear _opener global variable
607 self.addCleanup(urllib.request.urlcleanup)
608
609 # Create a list of temporary files. Each item in the list is a file
610 # name (absolute path or relative to the current working directory).
611 # All files in this list will be deleted in the tearDown method. Note,
612 # this only helps to makes sure temporary files get deleted, but it
613 # does nothing about trying to close files that may still be open. It
614 # is the responsibility of the developer to properly close files even
615 # when exceptional conditions occur.
616 self.tempFiles = []
617
618 # Create a temporary file.
619 self.registerFileForCleanUp(os_helper.TESTFN)
620 self.text = b'testing urllib.urlretrieve'
621 try:
622 FILE = open(os_helper.TESTFN, 'wb')
623 FILE.write(self.text)
624 FILE.close()
625 finally:
626 try: FILE.close()
627 except: pass
628
629 def tearDown(self):
630 # Delete the temporary files.

Callers

nothing calls this directly

Calls 5

addCleanupMethod · 0.80
openFunction · 0.50
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected