<s> """<STR_LIT>""" <EOL> import os <EOL> import sys <EOL> import re <EOL> import base64 <EOL> import shutil <EOL> import urllib <EOL> import httplib <EOL> import tempfile <EOL> import unittest <EOL> import CGIHTTPServer <EOL> from BaseHTTPServer import BaseHTTPRequestHandler , HTTPServer <EOL> from SimpleHTTPServer import SimpleHTTPRequestHandler <EOL> from CGIHTTPServer import CGIHTTPRequestHandler <EOL> from StringIO import StringIO <EOL> from test import test_support <EOL> threading = test_support . import_module ( '<STR_LIT>' ) <EOL> class NoLogRequestHandler : <EOL> def log_message ( self , * args ) : <EOL> pass <EOL> class SocketlessRequestHandler ( SimpleHTTPRequestHandler ) : <EOL> def __init__ ( self ) : <EOL> self . get_called = False <EOL> self . protocol_version = "<STR_LIT>" <EOL> def do_GET ( self ) : <EOL> self . get_called = True <EOL> self . send_response ( <NUM_LIT:200> ) <EOL> self . send_header ( '<STR_LIT:Content-Type>' , '<STR_LIT>' ) <EOL> self . end_headers ( ) <EOL> self . wfile . write ( b'<STR_LIT>' ) <EOL> def log_message ( self , fmt , * args ) : <EOL> pass <EOL> class TestServerThread ( threading . Thread ) : <EOL> def __init__ ( self , test_object , request_handler ) : <EOL> threading . Thread . __init__ ( self ) <EOL> self . request_handler = request_handler <EOL> self . test_object = test_object <EOL> def run ( self ) : <EOL> self . server = HTTPServer ( ( '<STR_LIT>' , <NUM_LIT:0> ) , self . request_handler ) <EOL> self . test_object . PORT = self . server . socket . getsockname ( ) [ <NUM_LIT:1> ] <EOL> self . test_object . server_started . set ( ) <EOL> self . test_object = None <EOL> try : <EOL> self . server . serve_forever ( <NUM_LIT> ) <EOL> finally : <EOL> self . server . server_close ( ) <EOL> def stop ( self ) : <EOL> self . server . shutdown ( ) <EOL> class BaseTestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . _threads = test_support . threading_setup ( ) <EOL> os . environ = test_support . EnvironmentVarGuard ( ) <EOL> self . server_started = threading . Event ( ) <EOL> self . thread = TestServerThread ( self , self . request_handler ) <EOL> self . thread . start ( ) <EOL> self . server_started . wait ( ) <EOL> def tearDown ( self ) : <EOL> self . thread . stop ( ) <EOL> os . environ . __exit__ ( ) <EOL> test_support . threading_cleanup ( * self . _threads ) <EOL> def request ( self , uri , method = '<STR_LIT:GET>' , body = None , headers = { } ) : <EOL> self . connection = httplib . HTTPConnection ( '<STR_LIT:localhost>' , self . PORT ) <EOL> self . connection . request ( method , uri , body , headers ) <EOL> return self . connection . getresponse ( ) <EOL> class BaseHTTPRequestHandlerTestCase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> HTTPResponseMatch = re . compile ( '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> self . handler = SocketlessRequestHandler ( ) <EOL> def send_typical_request ( self , message ) : <EOL> input_msg = StringIO ( message ) <EOL> output = StringIO ( ) <EOL> self . handler . rfile = input_msg <EOL> self . handler . wfile = output <EOL> self . handler . handle_one_request ( ) <EOL> output . seek ( <NUM_LIT:0> ) <EOL> return output . readlines ( ) <EOL> def verify_get_called ( self ) : <EOL> self . assertTrue ( self . handler . get_called ) <EOL> def verify_expected_headers ( self , headers ) : <EOL> for fieldName in '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' : <EOL> self . assertEqual ( sum ( h . startswith ( fieldName ) for h in headers ) , <NUM_LIT:1> ) <EOL> def verify_http_server_response ( self , response ) : <EOL> match = self . HTTPResponseMatch . search ( response ) <EOL> self . assertIsNotNone ( match ) <EOL> def test_http_1_1 ( self ) : <EOL> result = self . send_typical_request ( '<STR_LIT>' ) <EOL> self . verify_http_server_response ( result [ <NUM_LIT:0> ] ) <EOL> self . verify_expected_headers ( result [ <NUM_LIT:1> : - <NUM_LIT:1> ] ) <EOL> self . verify_get_called ( ) <EOL> self . assertEqual ( result [ - <NUM_LIT:1> ] , '<STR_LIT>' ) <EOL> def test_http_1_0 ( self ) : <EOL> result = self . send_typical_request ( '<STR_LIT>' ) <EOL> self . verify_http_server_response ( result [ <NUM_LIT:0> ] ) <EOL> self . verify_expected_headers ( result [ <NUM_LIT:1> : - <NUM_LIT:1> ] ) <EOL> self . verify_get_called ( ) <EOL> self . assertEqual ( result [ - <NUM_LIT:1> ] , '<STR_LIT>' ) <EOL> def test_http_0_9 ( self ) : <EOL> result = self . send_typical_request ( '<STR_LIT>' ) <EOL> self . assertEqual ( len ( result ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( result [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> self . verify_get_called ( ) <EOL> def test_with_continue_1_0 ( self ) : <EOL> result = self . send_typical_request ( '<STR_LIT>' ) <EOL> self . verify_http_server_response ( result [ <NUM_LIT:0> ] ) <EOL> self . verify_expected_headers ( result [ <NUM_LIT:1> : - <NUM_LIT:1> ] ) <EOL> self . verify_get_called ( ) <EOL> self . assertEqual ( result [ - <NUM_LIT:1> ] , '<STR_LIT>' ) <EOL> def test_request_length ( self ) : <EOL> result = self . send_typical_request ( b'<STR_LIT>' + b'<STR_LIT:x>' * <NUM_LIT> ) <EOL> self . assertEqual ( result [ <NUM_LIT:0> ] , b'<STR_LIT>' ) <EOL> self . assertFalse ( self . handler . get_called ) <EOL> class BaseHTTPServerTestCase ( BaseTestCase ) : <EOL> class request_handler ( NoLogRequestHandler , BaseHTTPRequestHandler ) : <EOL> protocol_version = '<STR_LIT>' <EOL> default_request_version = '<STR_LIT>' <EOL> def do_TEST ( self ) : <EOL> self . send_response ( <NUM_LIT> ) <EOL> self . send_header ( '<STR_LIT:Content-Type>' , '<STR_LIT>' ) <EOL> self . send_header ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . end_headers ( ) <EOL> def do_KEEP ( self ) : <EOL> self . send_response ( <NUM_LIT> ) <EOL> self . send_header ( '<STR_LIT:Content-Type>' , '<STR_LIT>' ) <EOL> self . send_header ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . end_headers ( ) <EOL> def do_KEYERROR ( self ) : <EOL> self . send_error ( <NUM_LIT> ) <EOL> def do_CUSTOM ( self ) : <EOL> self . send_response ( <NUM_LIT> ) <EOL> self . send_header ( '<STR_LIT:Content-Type>' , '<STR_LIT>' ) <EOL> self . send_header ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . end_headers ( ) <EOL> def setUp ( self ) : <EOL> BaseTestCase . setUp ( self ) <EOL> self . con = httplib . HTTPConnection ( '<STR_LIT:localhost>' , self . PORT ) <EOL> self . con . connect ( ) <EOL> def test_command ( self ) : <EOL> self . con . request ( '<STR_LIT:GET>' , '<STR_LIT:/>' ) <EOL> res = self . con . getresponse ( ) <EOL> self . assertEqual ( res . status , <NUM_LIT> ) <EOL> def test_request_line_trimming ( self ) : <EOL> self . con . _http_vsn_str = '<STR_LIT>' <EOL> self . con . putrequest ( '<STR_LIT:GET>' , '<STR_LIT:/>' ) <EOL> self . con . endheaders ( ) <EOL> res = self . con . getresponse ( ) <EOL> self . assertEqual ( res . status , <NUM_LIT> ) <EOL> def test_version_bogus ( self ) : <EOL> self . con . _http_vsn_str = '<STR_LIT>' <EOL> self . con . putrequest ( '<STR_LIT:GET>' , '<STR_LIT:/>' ) <EOL> self . con . endheaders ( ) <EOL> res = self . con . getresponse ( ) <EOL> self . assertEqual ( res . status , <NUM_LIT> ) <EOL> def test_version_digits ( self ) : <EOL> self . con . _http_vsn_str = '<STR_LIT>' <EOL> self . con . putrequest ( '<STR_LIT:GET>' , '<STR_LIT:/>' ) <EOL> self . con . endheaders ( ) <EOL> res = self . con . getresponse ( ) <EOL> self . assertEqual ( res . status , <NUM_LIT> ) <EOL> def test_version_none_get ( self ) : <EOL> self . con . _http_vsn_str = '<STR_LIT>' <EOL> self . con . putrequest ( '<STR_LIT:GET>' , '<STR_LIT:/>' ) <EOL> self . con . endheaders ( ) <EOL> res = self . con . getresponse ( ) <EOL> self . assertEqual ( res . status , <NUM_LIT> ) <EOL> def test_version_none ( self ) : <EOL> self . con . _http_vsn_str = '<STR_LIT>' <EOL> self . con . putrequest ( '<STR_LIT>' , '<STR_LIT:/>' ) <EOL> self . con . endheaders ( ) <EOL> res = self . con . getresponse ( ) <EOL> self . assertEqual ( res . status , <NUM_LIT> ) <EOL> def test_version_invalid ( self ) : <EOL> self . con . _http_vsn = <NUM_LIT> <EOL> self . con . _http_vsn_str = '<STR_LIT>' <EOL> self . con . putrequest ( '<STR_LIT:GET>' , '<STR_LIT:/>' ) <EOL> self . con . endheaders ( ) <EOL> res = self . con . getresponse ( ) <EOL> self . assertEqual ( res . status , <NUM_LIT> ) <EOL> def test_send_blank ( self ) : <EOL> self . con . _http_vsn_str = '<STR_LIT>' <EOL> self . con . putrequest ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . con . endheaders ( ) <EOL> res = self . con . getresponse ( ) <EOL> self . assertEqual ( res . status , <NUM_LIT> ) <EOL> def test_header_close ( self ) : <EOL> self . con . putrequest ( '<STR_LIT:GET>' , '<STR_LIT:/>' ) <EOL> self . con . putheader ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . con . endheaders ( ) <EOL> res = self . con . getresponse ( ) <EOL> self . assertEqual ( res . status , <NUM_LIT> ) <EOL> def test_head_keep_alive ( self ) : <EOL> self . con . _http_vsn_str = '<STR_LIT>' <EOL> self . con . putrequest ( '<STR_LIT:GET>' , '<STR_LIT:/>' ) <EOL> self . con . putheader ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . con . endheaders ( ) <EOL> res = self . con . getresponse ( ) <EOL> self . assertEqual ( res . status , <NUM_LIT> ) <EOL> def test_handler ( self ) : <EOL> self . con . request ( '<STR_LIT>' , '<STR_LIT:/>' ) <EOL> res = self . con . getresponse ( ) <EOL> self . assertEqual ( res . status , <NUM_LIT> ) <EOL> def test_return_header_keep_alive ( self ) : <EOL> self . con . request ( '<STR_LIT>' , '<STR_LIT:/>' ) <EOL> res = self . con . getresponse ( ) <EOL> self . assertEqual ( res . getheader ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . con . request ( '<STR_LIT>' , '<STR_LIT:/>' ) <EOL> self . addCleanup ( self . con . close ) <EOL> def test_internal_key_error ( self ) : <EOL> self . con . request ( '<STR_LIT>' , '<STR_LIT:/>' ) <EOL> res = self . con . getresponse ( ) <EOL> self . assertEqual ( res . status , <NUM_LIT> ) <EOL> def test_return_custom_status ( self ) : <EOL> self . con . request ( '<STR_LIT>' , '<STR_LIT:/>' ) <EOL> res = self . con . getresponse ( ) <EOL> self . assertEqual ( res . status , <NUM_LIT> ) <EOL> class SimpleHTTPServerTestCase ( BaseTestCase ) : <EOL> class request_handler ( NoLogRequestHandler , SimpleHTTPRequestHandler ) : <EOL> pass <EOL> def setUp ( self ) : <EOL> BaseTestCase . setUp ( self ) <EOL> self . cwd = os . getcwd ( ) <EOL> basetempdir = tempfile . gettempdir ( ) <EOL> os . chdir ( basetempdir ) <EOL> self . data = '<STR_LIT>' <EOL> self . tempdir = tempfile . mkdtemp ( dir = basetempdir ) <EOL> self . tempdir_name = os . path . basename ( self . tempdir ) <EOL> temp = open ( os . path . join ( self . tempdir , '<STR_LIT:test>' ) , '<STR_LIT:wb>' ) <EOL> temp . write ( self . data ) <EOL> temp . close ( ) <EOL> def tearDown ( self ) : <EOL> try : <EOL> os . chdir ( self . cwd ) <EOL> try : <EOL> shutil . rmtree ( self . tempdir ) <EOL> except OSError : <EOL> pass <EOL> finally : <EOL> BaseTestCase . tearDown ( self ) <EOL> def check_status_and_reason ( self , response , status , data = None ) : <EOL> body = response . read ( ) <EOL> self . assertTrue ( response ) <EOL> self . assertEqual ( response . status , status ) <EOL> self . assertIsNotNone ( response . reason ) <EOL> if data : <EOL> self . assertEqual ( data , body ) <EOL> def test_get ( self ) : <EOL> response = self . request ( self . tempdir_name + '<STR_LIT>' ) <EOL> self . check_status_and_reason ( response , <NUM_LIT:200> , data = self . data ) <EOL> response = self . request ( self . tempdir_name + '<STR_LIT>' ) <EOL> self . check_status_and_reason ( response , <NUM_LIT> ) <EOL> response = self . request ( self . tempdir_name + '<STR_LIT:/>' ) <EOL> self . check_status_and_reason ( response , <NUM_LIT:200> ) <EOL> response = self . request ( self . tempdir_name ) <EOL> self . check_status_and_reason ( response , <NUM_LIT> ) <EOL> response = self . request ( '<STR_LIT>' ) <EOL> self . check_status_and_reason ( response , <NUM_LIT> ) <EOL> response = self . request ( '<STR_LIT:/>' + '<STR_LIT>' + '<STR_LIT:/>' ) <EOL> self . check_status_and_reason ( response , <NUM_LIT> ) <EOL> with open ( os . path . join ( self . tempdir_name , '<STR_LIT>' ) , '<STR_LIT:w>' ) as fp : <EOL> response = self . request ( '<STR_LIT:/>' + self . tempdir_name + '<STR_LIT:/>' ) <EOL> self . check_status_and_reason ( response , <NUM_LIT:200> ) <EOL> if os . name == '<STR_LIT>' and os . geteuid ( ) != <NUM_LIT:0> : <EOL> os . chmod ( self . tempdir , <NUM_LIT:0> ) <EOL> response = self . request ( self . tempdir_name + '<STR_LIT:/>' ) <EOL> self . check_status_and_reason ( response , <NUM_LIT> ) <EOL> os . chmod ( self . tempdir , <NUM_LIT:0> <NUM_LIT> ) <EOL> def test_head ( self ) : <EOL> response = self . request ( <EOL> self . tempdir_name + '<STR_LIT>' , method = '<STR_LIT>' ) <EOL> self . check_status_and_reason ( response , <NUM_LIT:200> ) <EOL> self . assertEqual ( response . getheader ( '<STR_LIT>' ) , <EOL> str ( len ( self . data ) ) ) <EOL> self . assertEqual ( response . getheader ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_invalid_requests ( self ) : <EOL> response = self . request ( '<STR_LIT:/>' , method = '<STR_LIT>' ) <EOL> self . check_status_and_reason ( response , <NUM_LIT> ) <EOL> response = self . request ( '<STR_LIT:/>' , method = '<STR_LIT>' ) <EOL> self . check_status_and_reason ( response , <NUM_LIT> ) <EOL> response = self . request ( '<STR_LIT:/>' , method = '<STR_LIT>' ) <EOL> self . check_status_and_reason ( response , <NUM_LIT> ) <EOL> cgi_file1 = """<STR_LIT>""" <EOL> cgi_file2 = """<STR_LIT>""" <EOL> @ unittest . skipIf ( hasattr ( os , '<STR_LIT>' ) and os . geteuid ( ) == <NUM_LIT:0> , <EOL> "<STR_LIT>" ) <EOL> class CGIHTTPServerTestCase ( BaseTestCase ) : <EOL> class request_handler ( NoLogRequestHandler , CGIHTTPRequestHandler ) : <EOL> pass <EOL> def setUp ( self ) : <EOL> BaseTestCase . setUp ( self ) <EOL> self . parent_dir = tempfile . mkdtemp ( ) <EOL> self . cgi_dir = os . path . join ( self . parent_dir , '<STR_LIT>' ) <EOL> os . mkdir ( self . cgi_dir ) <EOL> if hasattr ( os , '<STR_LIT>' ) : <EOL> self . pythonexe = os . path . join ( self . parent_dir , '<STR_LIT>' ) <EOL> os . symlink ( sys . executable , self . pythonexe ) <EOL> else : <EOL> self . pythonexe = sys . executable <EOL> self . nocgi_path = os . path . join ( self . parent_dir , '<STR_LIT>' ) <EOL> with open ( self . nocgi_path , '<STR_LIT:w>' ) as fp : <EOL> fp . write ( cgi_file1 % self . pythonexe ) <EOL> os . chmod ( self . nocgi_path , <NUM_LIT:0> <NUM_LIT> ) <EOL> self . file1_path = os . path . join ( self . cgi_dir , '<STR_LIT>' ) <EOL> with open ( self . file1_path , '<STR_LIT:w>' ) as file1 : <EOL> file1 . write ( cgi_file1 % self . pythonexe ) <EOL> os . chmod ( self . file1_path , <NUM_LIT:0> <NUM_LIT> ) <EOL> self . file2_path = os . path . join ( self . cgi_dir , '<STR_LIT>' ) <EOL> with open ( self . file2_path , '<STR_LIT:w>' ) as file2 : <EOL> file2 . write ( cgi_file2 % self . pythonexe ) <EOL> os . chmod ( self . file2_path , <NUM_LIT:0> <NUM_LIT> ) <EOL> self . cwd = os . getcwd ( ) <EOL> os . chdir ( self . parent_dir ) <EOL> def tearDown ( self ) : <EOL> try : <EOL> os . chdir ( self . cwd ) <EOL> if self . pythonexe != sys . executable : <EOL> os . remove ( self . pythonexe ) <EOL> os . remove ( self . nocgi_path ) <EOL> os . remove ( self . file1_path ) <EOL> os . remove ( self . file2_path ) <EOL> os . rmdir ( self . cgi_dir ) <EOL> os . rmdir ( self . parent_dir ) <EOL> finally : <EOL> BaseTestCase . tearDown ( self ) <EOL> def test_url_collapse_path ( self ) : <EOL> test_vectors = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:..>' : IndexError , <EOL> '<STR_LIT>' : IndexError , <EOL> '<STR_LIT:/>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:a>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : IndexError , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : IndexError , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> for path , expected in test_vectors . iteritems ( ) : <EOL> if isinstance ( expected , type ) and issubclass ( expected , Exception ) : <EOL> self . assertRaises ( expected , <EOL> CGIHTTPServer . _url_collapse_path , path ) <EOL> else : <EOL> actual = CGIHTTPServer . _url_collapse_path ( path ) <EOL> self . assertEqual ( expected , actual , <EOL> msg = '<STR_LIT>' % <EOL> ( path , actual , expected ) ) <EOL> def test_headers_and_content ( self ) : <EOL> res = self . request ( '<STR_LIT>' ) <EOL> self . assertEqual ( ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:200> ) , <EOL> ( res . read ( ) , res . getheader ( '<STR_LIT>' ) , res . status ) ) <EOL> def test_issue19435 ( self ) : <EOL> res = self . request ( '<STR_LIT>' ) <EOL> self . assertEqual ( res . status , <NUM_LIT> ) <EOL> def test_post ( self ) : <EOL> params = urllib . urlencode ( { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> } ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> res = self . request ( '<STR_LIT>' , '<STR_LIT:POST>' , params , headers ) <EOL> self . assertEqual ( res . read ( ) , '<STR_LIT>' ) <EOL> def test_invaliduri ( self ) : <EOL> res = self . request ( '<STR_LIT>' ) <EOL> res . read ( ) <EOL> self . assertEqual ( res . status , <NUM_LIT> ) <EOL> def test_authorization ( self ) : <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' % <EOL> base64 . b64encode ( '<STR_LIT>' ) } <EOL> res = self . request ( '<STR_LIT>' , '<STR_LIT:GET>' , headers = headers ) <EOL> self . assertEqual ( ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:200> ) , <EOL> ( res . read ( ) , res . getheader ( '<STR_LIT>' ) , res . status ) ) <EOL> def test_no_leading_slash ( self ) : <EOL> res = self . request ( '<STR_LIT>' ) <EOL> self . assertEqual ( ( '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:200> ) , <EOL> ( res . read ( ) , res . getheader ( '<STR_LIT>' ) , res . status ) ) <EOL> def test_os_environ_is_not_altered ( self ) : <EOL> signature = "<STR_LIT>" <EOL> os . environ [ '<STR_LIT>' ] = signature <EOL> res = self . request ( '<STR_LIT>' ) <EOL> self . assertEqual ( ( b'<STR_LIT>' , '<STR_LIT>' , <NUM_LIT:200> ) , <EOL> ( res . read ( ) , res . getheader ( '<STR_LIT>' ) , res . status ) ) <EOL> self . assertEqual ( os . environ [ '<STR_LIT>' ] , signature ) <EOL> class SimpleHTTPRequestHandlerTestCase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . translated = os . getcwd ( ) <EOL> self . translated = os . path . join ( self . translated , '<STR_LIT:filename>' ) <EOL> self . handler = SocketlessRequestHandler ( ) <EOL> def test_query_arguments ( self ) : <EOL> path = self . handler . translate_path ( '<STR_LIT>' ) <EOL> self . assertEqual ( path , self . translated ) <EOL> path = self . handler . translate_path ( '<STR_LIT>' ) <EOL> self . assertEqual ( path , self . translated ) <EOL> path = self . handler . translate_path ( '<STR_LIT>' ) <EOL> self . assertEqual ( path , self . translated ) <EOL> def test_start_with_double_slash ( self ) : <EOL> path = self . handler . translate_path ( '<STR_LIT>' ) <EOL> self . assertEqual ( path , self . translated ) <EOL> path = self . handler . translate_path ( '<STR_LIT>' ) <EOL> self . assertEqual ( path , self . translated ) <EOL> def test_main ( verbose = None ) : <EOL> try : <EOL> cwd = os . getcwd ( ) <EOL> test_support . run_unittest ( BaseHTTPRequestHandlerTestCase , <EOL> SimpleHTTPRequestHandlerTestCase , <EOL> BaseHTTPServerTestCase , <EOL> SimpleHTTPServerTestCase , <EOL> CGIHTTPServerTestCase <EOL> ) <EOL> finally : <EOL> os . chdir ( cwd ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> test_main ( ) </s>
