Creates a new temporary file containing the specified data, registers the file for deletion during the test fixture tear down, and returns the absolute path of the file.
(self, data=b"")
| 637 | return urllib.request.pathname2url(filePath, add_scheme=True) |
| 638 | |
| 639 | def createNewTempFile(self, data=b""): |
| 640 | """Creates a new temporary file containing the specified data, |
| 641 | registers the file for deletion during the test fixture tear down, and |
| 642 | returns the absolute path of the file.""" |
| 643 | |
| 644 | newFd, newFilePath = tempfile.mkstemp() |
| 645 | try: |
| 646 | self.registerFileForCleanUp(newFilePath) |
| 647 | newFile = os.fdopen(newFd, "wb") |
| 648 | newFile.write(data) |
| 649 | newFile.close() |
| 650 | finally: |
| 651 | try: newFile.close() |
| 652 | except: pass |
| 653 | return newFilePath |
| 654 | |
| 655 | def registerFileForCleanUp(self, fileName): |
| 656 | self.tempFiles.append(fileName) |
no test coverage detected