mirror of https://github.com/python/cpython
Move test_SimpleHTTPServer into test_httpservers.
This commit is contained in:
parent
65e5f80c48
commit
6fcac0d6f6
|
@ -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()
|
|
|
@ -401,12 +401,40 @@ class CGIHTTPServerTestCase(BaseTestCase):
|
||||||
(res.read(), res.getheader('Content-type'), res.status))
|
(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):
|
def test_main(verbose=None):
|
||||||
try:
|
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
support.run_unittest(BaseHTTPServerTestCase,
|
try:
|
||||||
|
support.run_unittest(
|
||||||
|
BaseHTTPServerTestCase,
|
||||||
SimpleHTTPServerTestCase,
|
SimpleHTTPServerTestCase,
|
||||||
CGIHTTPServerTestCase
|
CGIHTTPServerTestCase,
|
||||||
|
SimpleHTTPRequestHandlerTestCase,
|
||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
|
|
Loading…
Reference in New Issue