From 2a476148e3a5ea296d1108129475e8b910778a2c Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Thu, 22 Mar 2018 19:35:36 +0000 Subject: [PATCH 1/2] Undo patches in teardown before attempting to delete files --- notebook/tests/launchnotebook.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebook/tests/launchnotebook.py b/notebook/tests/launchnotebook.py index 43c98814a..1b685df0c 100644 --- a/notebook/tests/launchnotebook.py +++ b/notebook/tests/launchnotebook.py @@ -178,9 +178,9 @@ class NotebookTestBase(TestCase): def teardown_class(cls): cls.notebook.stop() cls.wait_until_dead() - cls.tmp_dir.cleanup() cls.env_patch.stop() cls.path_patch.stop() + cls.tmp_dir.cleanup() # cleanup global zmq Context, to ensure we aren't leaving dangling sockets def cleanup_zmq(): zmq.Context.instance().term() From acbeaf80fe806c3183a26065c75e5f1064633cb0 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Thu, 22 Mar 2018 20:01:02 +0000 Subject: [PATCH 2/2] Try testing redirect without requesting target file --- notebook/tree/tests/test_tree_handler.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/notebook/tree/tests/test_tree_handler.py b/notebook/tree/tests/test_tree_handler.py index d2271a058..dabb23117 100644 --- a/notebook/tree/tests/test_tree_handler.py +++ b/notebook/tree/tests/test_tree_handler.py @@ -4,6 +4,10 @@ import io from notebook.utils import url_path_join from nbformat import write from nbformat.v4 import new_notebook +try: + from urllib.parse import urlparse +except ImportError: + from urlparse import urlparse import requests @@ -28,5 +32,7 @@ class TreeTest(NotebookTestBase): r = self.request('GET', 'tree/foo/bar.ipynb') self.assertEqual(r.url, self.base_url() + 'notebooks/foo/bar.ipynb') - r = self.request('GET', 'tree/foo/baz.txt') - self.assertEqual(r.url, url_path_join(self.base_url(), 'files/foo/baz.txt')) + r = self.request('GET', 'tree/foo/baz.txt', allow_redirects=False) + self.assertEqual(r.status_code, 302) + self.assertEqual(r.headers['Location'], + urlparse(url_path_join(self.base_url(), 'files/foo/baz.txt')).path)