Show More
@@ -141,7 +141,7 b' class APITest(NotebookTestBase):' | |||
|
141 | 141 | os.makedirs(os_path) |
|
142 | 142 | except OSError: |
|
143 | 143 | print("Directory already exists: %r" % os_path) |
|
144 | ||
|
144 | ||
|
145 | 145 | def make_txt(self, api_path, txt): |
|
146 | 146 | """Make a text file at a given api_path""" |
|
147 | 147 | os_path = self.to_os_path(api_path) |
@@ -160,6 +160,16 b' class APITest(NotebookTestBase):' | |||
|
160 | 160 | |
|
161 | 161 | with io.open(os_path, 'w', encoding='utf-8') as f: |
|
162 | 162 | write(nb, f, version=4) |
|
163 | ||
|
164 | def delete_dir(self, api_path): | |
|
165 | """Delete a directory at api_path, removing any contents.""" | |
|
166 | os_path = self.to_os_path(api_path) | |
|
167 | shutil.rmtree(os_path, ignore_errors=True) | |
|
168 | ||
|
169 | def delete_file(self, api_path): | |
|
170 | """Delete a file at the given path if it exists.""" | |
|
171 | if self.isfile(api_path): | |
|
172 | os.unlink(self.to_os_path(api_path)) | |
|
163 | 173 | |
|
164 | 174 | def isfile(self, api_path): |
|
165 | 175 | return os.path.isfile(self.to_os_path(api_path)) |
@@ -190,13 +200,9 b' class APITest(NotebookTestBase):' | |||
|
190 | 200 | self.api = API(self.base_url()) |
|
191 | 201 | |
|
192 | 202 | def tearDown(self): |
|
193 | nbdir = self.notebook_dir.name | |
|
194 | ||
|
195 | 203 | for dname in (list(self.top_level_dirs) + self.hidden_dirs): |
|
196 | shutil.rmtree(pjoin(nbdir, dname), ignore_errors=True) | |
|
197 | ||
|
198 | if os.path.isfile(pjoin(nbdir, 'inroot.ipynb')): | |
|
199 | os.unlink(pjoin(nbdir, 'inroot.ipynb')) | |
|
204 | self.delete_dir(dname) | |
|
205 | self.delete_file('inroot.ipynb') | |
|
200 | 206 | |
|
201 | 207 | def test_list_notebooks(self): |
|
202 | 208 | nbs = notebooks_only(self.api.list().json()) |
General Comments 0
You need to be logged in to leave comments.
Login now