##// END OF EJS Templates
remove mktemp usage...
Julian Taylor -
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:
@@ -95,7 +95,8 b' def write_connection_file(fname=None, shell_port=0, iopub_port=0, stdin_port=0, '
95 95 ip = localhost()
96 96 # default to temporary connector file
97 97 if not fname:
98 fname = tempfile.mktemp('.json')
98 fd, fname = tempfile.mkstemp('.json')
99 os.close(fd)
99 100
100 101 # Find open ports as necessary.
101 102
@@ -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
@@ -21,7 +21,7 b' import sys'
21 21 import platform
22 22 import time
23 23 from collections import namedtuple
24 from tempfile import mktemp
24 from tempfile import NamedTemporaryFile
25 25
26 26 import zmq
27 27 from nose.plugins.attrib import attr
@@ -164,13 +164,12 b' class TestView(ClusterTestCase):'
164 164
165 165 def test_run_newline(self):
166 166 """test that run appends newline to files"""
167 tmpfile = mktemp()
168 with open(tmpfile, 'w') as f:
167 with NamedTemporaryFile('w', delete=False) as f:
169 168 f.write("""def g():
170 169 return 5
171 170 """)
172 171 v = self.client[-1]
173 v.run(tmpfile, block=True)
172 v.run(f.name, block=True)
174 173 self.assertEqual(v.apply_sync(lambda f: f(), pmod.Reference('g')), 5)
175 174
176 175 def test_apply_tracked(self):
@@ -152,7 +152,9 b' def default_config():'
152 152 config.TerminalInteractiveShell.colors = 'NoColor'
153 153 config.TerminalTerminalInteractiveShell.term_title = False,
154 154 config.TerminalInteractiveShell.autocall = 0
155 config.HistoryManager.hist_file = tempfile.mktemp(u'test_hist.sqlite')
155 f = tempfile.NamedTemporaryFile(suffix=u'test_hist.sqlite', delete=False)
156 config.HistoryManager.hist_file = f.name
157 f.close()
156 158 config.HistoryManager.db_cache_size = 10000
157 159 return config
158 160
General Comments 0
You need to be logged in to leave comments. Login now