MCPcopy Index your code
hub / github.com/RustPython/RustPython / TempFile

Class TempFile

Lib/test/test_lzma.py:527–539  ·  view source on GitHub ↗

Context manager - creates a file, and deletes it on __exit__.

Source from the content-addressed store, hash-verified

525
526
527class TempFile:
528 """Context manager - creates a file, and deletes it on __exit__."""
529
530 def __init__(self, filename, data=b""):
531 self.filename = filename
532 self.data = data
533
534 def __enter__(self):
535 with open(self.filename, "wb") as f:
536 f.write(self.data)
537
538 def __exit__(self, *args):
539 unlink(self.filename)
540
541
542class FileTestCase(unittest.TestCase):

Callers 11

test_init_modeMethod · 0.70
test_closeMethod · 0.70
test_filenoMethod · 0.70
test_read_from_fileMethod · 0.70
test_filenameMethod · 0.70

Calls

no outgoing calls

Tested by 11

test_init_modeMethod · 0.56
test_closeMethod · 0.56
test_filenoMethod · 0.56
test_read_from_fileMethod · 0.56
test_filenameMethod · 0.56