]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Make test_root_static_path more robust. 1567/head
authorBen Darnell <ben@bendarnell.com>
Sat, 24 Oct 2015 13:57:16 +0000 (09:57 -0400)
committerBen Darnell <ben@bendarnell.com>
Sat, 24 Oct 2015 13:57:16 +0000 (09:57 -0400)
Always convert `__file__` to an absolute path (this is already
guaranteed in Python 3.4+, but in older versions it would sometimes be
relative). Encode the path so the test can pass when run from a
directory containing spaces or other special characters.

Fixes #1565

tornado/test/web_test.py

index fe7e4c1bf8eb42452987efd7727e910abaf7b26b..a734a40e317a6052fe53e926dd7ac47bbda6da0a 100644 (file)
@@ -1218,8 +1218,9 @@ class StaticFileTest(WebTestCase):
         # to disable Tornado's path validation (in conjunction with
         # their own validation in get_absolute_path). Make sure
         # that the stricter validation in 4.2.1 doesn't break them.
-        path = os.path.join(os.path.dirname(__file__), 'static/robots.txt')
-        response = self.get_and_head('/root_static' + path)
+        path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                            'static/robots.txt')
+        response = self.get_and_head('/root_static' + urllib_parse.quote(path))
         self.assertEqual(response.code, 200)