1 """ 2 These tests only check url parsing for now. 3 We don't want to require the 'network' resource. 4 """ 5 6 import os, unittest 7 from SimpleHTTPServer import SimpleHTTPRequestHandler 8 from test import test_support 9 10 11 class SocketlessRequestHandler (SimpleHTTPRequestHandler): 12 def __init__(self): 13 pass 14 15 class 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 37 def test_main(): 38 test_support.run_unittest(SimpleHTTPRequestHandlerTestCase) 39 40 if __name__ == "__main__": 41 test_main() 42