1""" 2These tests only check url parsing for now. 3We don't want to require the 'network' resource. 4""" 5 6import os, unittest 7from SimpleHTTPServer import SimpleHTTPRequestHandler 8from test import test_support 9 10 11class SocketlessRequestHandler (SimpleHTTPRequestHandler): 12 def __init__(self): 13 pass 14 15class SimpleHTTPRequestHandlerTestCase(unittest.TestCase): 16 """ Test url parsing """ 17 def setUp (self): 18 self.translated = os.getcwd() 19 self.translated = os.path.join(self.translated, 'filename') 20 self.handler = SocketlessRequestHandler () 21 22 def test_queryArguments (self): 23 path = self.handler.translate_path ('/filename') 24 self.assertEqual (path, self.translated) 25 path = self.handler.translate_path ('/filename?foo=bar') 26 self.assertEqual (path, self.translated) 27 path = self.handler.translate_path ('/filename?a=b&spam=eggs#zot') 28 self.assertEqual (path, self.translated) 29 30 def test_startWithDoubleSlash (self): 31 path = self.handler.translate_path ('//filename') 32 self.assertEqual (path, self.translated) 33 path = self.handler.translate_path ('//filename?foo=bar') 34 self.assertEqual (path, self.translated) 35 36 37def test_main(): 38 test_support.run_unittest(SimpleHTTPRequestHandlerTestCase) 39 40if __name__ == "__main__": 41 test_main() 42