Show More
@@ -3086,6 +3086,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
3086 | self.tempdirs.append(dirname) |
|
3086 | self.tempdirs.append(dirname) | |
3087 |
|
3087 | |||
3088 | handle, filename = tempfile.mkstemp('.py', prefix, dir=dirname) |
|
3088 | handle, filename = tempfile.mkstemp('.py', prefix, dir=dirname) | |
|
3089 | os.close(handle) # On Windows, there can only be one open handle on a file | |||
3089 | self.tempfiles.append(filename) |
|
3090 | self.tempfiles.append(filename) | |
3090 |
|
3091 | |||
3091 | if data: |
|
3092 | if data: |
@@ -462,6 +462,15 b' class InteractiveShellTestCase(unittest.TestCase):' | |||||
462 | ip.run_cell("d = 1/2", shell_futures=True) |
|
462 | ip.run_cell("d = 1/2", shell_futures=True) | |
463 | self.assertEqual(ip.user_ns['d'], 0) |
|
463 | self.assertEqual(ip.user_ns['d'], 0) | |
464 |
|
464 | |||
|
465 | def test_mktempfile(self): | |||
|
466 | filename = ip.mktempfile() | |||
|
467 | # Check that we can open the file again on Windows | |||
|
468 | with open(filename, 'w') as f: | |||
|
469 | f.write('abc') | |||
|
470 | ||||
|
471 | filename = ip.mktempfile(data='blah') | |||
|
472 | with open(filename, 'r') as f: | |||
|
473 | self.assertEqual(f.read(), 'blah') | |||
465 |
|
474 | |||
466 | class TestSafeExecfileNonAsciiPath(unittest.TestCase): |
|
475 | class TestSafeExecfileNonAsciiPath(unittest.TestCase): | |
467 |
|
476 |
General Comments 0
You need to be logged in to leave comments.
Login now