mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-24 12:05:22 +08:00
Make sessions REST API test more robust.
Was seeing failures on Windows because it failed to delete the folder.
This commit is contained in:
parent
0e9a7c0874
commit
93ee2d7173
@ -1,5 +1,6 @@
|
|||||||
"""Test the sessions web service API."""
|
"""Test the sessions web service API."""
|
||||||
|
|
||||||
|
import errno
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
@ -51,7 +52,12 @@ class SessionAPITest(NotebookTestBase):
|
|||||||
"""Test the sessions web service API"""
|
"""Test the sessions web service API"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
nbdir = self.notebook_dir.name
|
nbdir = self.notebook_dir.name
|
||||||
|
try:
|
||||||
os.mkdir(pjoin(nbdir, 'foo'))
|
os.mkdir(pjoin(nbdir, 'foo'))
|
||||||
|
except OSError as e:
|
||||||
|
# Deleting the folder in an earlier test may have failed
|
||||||
|
if e.errno != errno.EEXIST:
|
||||||
|
raise
|
||||||
|
|
||||||
with io.open(pjoin(nbdir, 'foo', 'nb1.ipynb'), 'w') as f:
|
with io.open(pjoin(nbdir, 'foo', 'nb1.ipynb'), 'w') as f:
|
||||||
nb = new_notebook(name='nb1')
|
nb = new_notebook(name='nb1')
|
||||||
@ -62,7 +68,8 @@ class SessionAPITest(NotebookTestBase):
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
for session in self.sess_api.list().json():
|
for session in self.sess_api.list().json():
|
||||||
self.sess_api.delete(session['id'])
|
self.sess_api.delete(session['id'])
|
||||||
shutil.rmtree(pjoin(self.notebook_dir.name, 'foo'))
|
shutil.rmtree(pjoin(self.notebook_dir.name, 'foo'),
|
||||||
|
ignore_errors=True)
|
||||||
|
|
||||||
def test_create(self):
|
def test_create(self):
|
||||||
sessions = self.sess_api.list().json()
|
sessions = self.sess_api.list().json()
|
||||||
|
Loading…
Reference in New Issue
Block a user