PageRenderTime 13ms CodeModel.GetById 10ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/Lib/test/test_SimpleHTTPServer.py

http://unladen-swallow.googlecode.com/
Python | 41 lines | 27 code | 0 blank | 14 comment | 0 complexity | 4e942fe9eddd3b0a8271b544fb899eac MD5 | raw file
 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.assertEquals (path, self.translated)
25        path = self.handler.translate_path ('/filename?foo=bar')
26        self.assertEquals (path, self.translated)
27        path = self.handler.translate_path ('/filename?a=b&spam=eggs#zot')
28        self.assertEquals (path, self.translated)
29
30    def test_startWithDoubleSlash (self):
31        path = self.handler.translate_path ('//filename')
32        self.assertEquals (path, self.translated)
33        path = self.handler.translate_path ('//filename?foo=bar')
34        self.assertEquals (path, self.translated)
35
36
37def test_main():
38    test_support.run_unittest(SimpleHTTPRequestHandlerTestCase)
39
40if __name__ == "__main__":
41    test_main()