##// END OF EJS Templates
Make sessions REST API test more robust....
Thomas Kluyver -
Show More
@@ -1,5 +1,6 b''
1 """Test the sessions web service API."""
1 """Test the sessions web service API."""
2
2
3 import errno
3 import io
4 import io
4 import os
5 import os
5 import json
6 import json
@@ -51,7 +52,12 b' class SessionAPITest(NotebookTestBase):'
51 """Test the sessions web service API"""
52 """Test the sessions web service API"""
52 def setUp(self):
53 def setUp(self):
53 nbdir = self.notebook_dir.name
54 nbdir = self.notebook_dir.name
54 os.mkdir(pjoin(nbdir, 'foo'))
55 try:
56 os.mkdir(pjoin(nbdir, 'foo'))
57 except OSError as e:
58 # Deleting the folder in an earlier test may have failed
59 if e.errno != errno.EEXIST:
60 raise
55
61
56 with io.open(pjoin(nbdir, 'foo', 'nb1.ipynb'), 'w') as f:
62 with io.open(pjoin(nbdir, 'foo', 'nb1.ipynb'), 'w') as f:
57 nb = new_notebook(name='nb1')
63 nb = new_notebook(name='nb1')
@@ -62,7 +68,8 b' class SessionAPITest(NotebookTestBase):'
62 def tearDown(self):
68 def tearDown(self):
63 for session in self.sess_api.list().json():
69 for session in self.sess_api.list().json():
64 self.sess_api.delete(session['id'])
70 self.sess_api.delete(session['id'])
65 shutil.rmtree(pjoin(self.notebook_dir.name, 'foo'))
71 shutil.rmtree(pjoin(self.notebook_dir.name, 'foo'),
72 ignore_errors=True)
66
73
67 def test_create(self):
74 def test_create(self):
68 sessions = self.sess_api.list().json()
75 sessions = self.sess_api.list().json()
General Comments 0
You need to be logged in to leave comments. Login now