##// END OF EJS Templates
use a temporary directory for js tests
Paul Ivanov -
Show More
@@ -166,6 +166,10 b' class JSController(TestController):'
166 TestController.__init__(self)
166 TestController.__init__(self)
167 self.section = section
167 self.section = section
168
168
169 self.ipydir = TemporaryDirectory()
170 self.dirs.append(self.ipydir)
171 self.env['IPYTHONDIR'] = self.ipydir.name
172
169 # start the ipython notebook, so we get the port number
173 # start the ipython notebook, so we get the port number
170 self._init_server()
174 self._init_server()
171
175
@@ -180,20 +184,21 b' class JSController(TestController):'
180 def _init_server(self):
184 def _init_server(self):
181 "Start the notebook server in a separate process"
185 "Start the notebook server in a separate process"
182 self.queue = q = Queue()
186 self.queue = q = Queue()
183 self.server = server = Process(target=run_webapp, args=(q,))
187 self.server = Process(target=run_webapp, args=(q, self.ipydir.name))
184 server.start()
188 self.server.start()
185 self.server_port = q.get()
189 self.server_port = q.get()
186
190
187 def cleanup(self):
191 def cleanup(self):
188 self.server.terminate()
192 self.server.terminate()
193 self.server.join()
189 TestController.cleanup(self)
194 TestController.cleanup(self)
190
195
191
196
192 def run_webapp(q):
197 def run_webapp(q, nbdir):
193 """start the IPython Notebook, and pass port back to the queue"""
198 """start the IPython Notebook, and pass port back to the queue"""
194 import IPython.html.notebookapp as nbapp
199 import IPython.html.notebookapp as nbapp
195 server = nbapp.NotebookApp()
200 server = nbapp.NotebookApp()
196 server.initialize(['--no-browser'])
201 server.initialize(['--no-browser', '--notebook-dir='+nbdir])
197 # communicate the port number to the parent process
202 # communicate the port number to the parent process
198 q.put(server.port)
203 q.put(server.port)
199 server.start()
204 server.start()
General Comments 0
You need to be logged in to leave comments. Login now