diff --git a/Lib/test/test_SimpleHTTPServer.py b/Lib/test/test_SimpleHTTPServer.py deleted file mode 100644 index 36c2b89d786..00000000000 --- a/Lib/test/test_SimpleHTTPServer.py +++ /dev/null @@ -1,41 +0,0 @@ -""" -These tests only check url parsing for now. -We don't want to require the 'network' resource. -""" - -import os, unittest -from http.server import SimpleHTTPRequestHandler -from test import support - - -class SocketlessRequestHandler(SimpleHTTPRequestHandler): - def __init__(self): - pass - -class SimpleHTTPRequestHandlerTestCase(unittest.TestCase): - """ Test url parsing """ - def setUp (self): - self.translated = os.getcwd() - self.translated = os.path.join(self.translated, 'filename') - self.handler = SocketlessRequestHandler () - - def test_queryArguments (self): - path = self.handler.translate_path ('/filename') - self.assertEquals (path, self.translated) - path = self.handler.translate_path ('/filename?foo=bar') - self.assertEquals (path, self.translated) - path = self.handler.translate_path ('/filename?a=b&spam=eggs#zot') - self.assertEquals (path, self.translated) - - def test_startWithDoubleSlash (self): - path = self.handler.translate_path ('//filename') - self.assertEquals (path, self.translated) - path = self.handler.translate_path ('//filename?foo=bar') - self.assertEquals (path, self.translated) - - -def test_main(): - support.run_unittest(SimpleHTTPRequestHandlerTestCase) - -if __name__ == "__main__": - test_main() diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py index 4895b650f58..b276c73c707 100644 --- a/Lib/test/test_httpservers.py +++ b/Lib/test/test_httpservers.py @@ -401,13 +401,41 @@ class CGIHTTPServerTestCase(BaseTestCase): (res.read(), res.getheader('Content-type'), res.status)) +class SocketlessRequestHandler(SimpleHTTPRequestHandler): + def __init__(self): + pass + +class SimpleHTTPRequestHandlerTestCase(unittest.TestCase): + """ Test url parsing """ + def setUp(self): + self.translated = os.getcwd() + self.translated = os.path.join(self.translated, 'filename') + self.handler = SocketlessRequestHandler() + + def test_query_arguments(self): + path = self.handler.translate_path('/filename') + self.assertEqual(path, self.translated) + path = self.handler.translate_path('/filename?foo=bar') + self.assertEqual(path, self.translated) + path = self.handler.translate_path('/filename?a=b&spam=eggs#zot') + self.assertEqual(path, self.translated) + + def test_start_with_double_slash(self): + path = self.handler.translate_path('//filename') + self.assertEqual(path, self.translated) + path = self.handler.translate_path('//filename?foo=bar') + self.assertEqual(path, self.translated) + + def test_main(verbose=None): + cwd = os.getcwd() try: - cwd = os.getcwd() - support.run_unittest(BaseHTTPServerTestCase, - SimpleHTTPServerTestCase, - CGIHTTPServerTestCase - ) + support.run_unittest( + BaseHTTPServerTestCase, + SimpleHTTPServerTestCase, + CGIHTTPServerTestCase, + SimpleHTTPRequestHandlerTestCase, + ) finally: os.chdir(cwd)