Show More
@@ -208,15 +208,18 b' def page(strng, start=0, screen_lines=0, pager_cmd=None):' | |||
|
208 | 208 | # The default WinXP 'type' command is failing on complex strings. |
|
209 | 209 | retval = 1 |
|
210 | 210 | else: |
|
211 | tmpname = tempfile.mktemp('.txt') | |
|
212 | tmpfile = open(tmpname,'wt') | |
|
211 | fd, tmpname = tempfile.mkstemp('.txt') | |
|
212 | try: | |
|
213 | os.close(fd) | |
|
214 | with open(tmpname, 'wt') as tmpfile: | |
|
213 | 215 | tmpfile.write(strng) |
|
214 | tmpfile.close() | |
|
215 | 216 | cmd = "%s < %s" % (pager_cmd,tmpname) |
|
217 | # tmpfile needs to be closed for windows | |
|
216 | 218 | if os.system(cmd): |
|
217 | 219 | retval = 1 |
|
218 | 220 | else: |
|
219 | 221 | retval = None |
|
222 | finally: | |
|
220 | 223 | os.remove(tmpname) |
|
221 | 224 | else: |
|
222 | 225 | try: |
@@ -92,7 +92,8 b' def write_connection_file(fname=None, shell_port=0, iopub_port=0, stdin_port=0, ' | |||
|
92 | 92 | """ |
|
93 | 93 | # default to temporary connector file |
|
94 | 94 | if not fname: |
|
95 | fname = tempfile.mktemp('.json') | |
|
95 | fd, fname = tempfile.mkstemp('.json') | |
|
96 | os.close(fd) | |
|
96 | 97 | |
|
97 | 98 | # Find open ports as necessary. |
|
98 | 99 |
@@ -20,7 +20,6 b' from __future__ import division' | |||
|
20 | 20 | |
|
21 | 21 | import time |
|
22 | 22 | from datetime import datetime |
|
23 | from tempfile import mktemp | |
|
24 | 23 | |
|
25 | 24 | import zmq |
|
26 | 25 |
@@ -20,7 +20,7 b' import sys' | |||
|
20 | 20 | import platform |
|
21 | 21 | import time |
|
22 | 22 | from collections import namedtuple |
|
23 |
from tempfile import |
|
|
23 | from tempfile import NamedTemporaryFile | |
|
24 | 24 | from StringIO import StringIO |
|
25 | 25 | |
|
26 | 26 | import zmq |
@@ -166,13 +166,12 b' class TestView(ClusterTestCase, ParametricTestCase):' | |||
|
166 | 166 | |
|
167 | 167 | def test_run_newline(self): |
|
168 | 168 | """test that run appends newline to files""" |
|
169 | tmpfile = mktemp() | |
|
170 | with open(tmpfile, 'w') as f: | |
|
169 | with NamedTemporaryFile('w', delete=False) as f: | |
|
171 | 170 | f.write("""def g(): |
|
172 | 171 | return 5 |
|
173 | 172 | """) |
|
174 | 173 | v = self.client[-1] |
|
175 |
v.run( |
|
|
174 | v.run(f.name, block=True) | |
|
176 | 175 | self.assertEqual(v.apply_sync(lambda f: f(), pmod.Reference('g')), 5) |
|
177 | 176 | |
|
178 | 177 | def test_apply_tracked(self): |
@@ -150,7 +150,9 b' def default_config():' | |||
|
150 | 150 | config.TerminalInteractiveShell.colors = 'NoColor' |
|
151 | 151 | config.TerminalTerminalInteractiveShell.term_title = False, |
|
152 | 152 | config.TerminalInteractiveShell.autocall = 0 |
|
153 | config.HistoryManager.hist_file = tempfile.mktemp(u'test_hist.sqlite') | |
|
153 | f = tempfile.NamedTemporaryFile(suffix=u'test_hist.sqlite', delete=False) | |
|
154 | config.HistoryManager.hist_file = f.name | |
|
155 | f.close() | |
|
154 | 156 | config.HistoryManager.db_cache_size = 10000 |
|
155 | 157 | return config |
|
156 | 158 |
General Comments 0
You need to be logged in to leave comments.
Login now