Back to index

python3.2  3.2.2
Public Member Functions
test.test_wsgiref.UtilityTests Class Reference
Inheritance diagram for test.test_wsgiref.UtilityTests:
Inheritance graph
[legend]
Collaboration diagram for test.test_wsgiref.UtilityTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def checkShift
def checkDefault
def checkCrossDefault
def checkAppURI
def checkReqURI
def checkFW
def testSimpleShifts
def testNormalizedShifts
def testDefaults
def testCrossDefaults
def testGuessScheme
def testAppURIs
def testReqURIs
def testFileWrapper
def testHopByHop

Detailed Description

Definition at line 200 of file test_wsgiref.py.


Member Function Documentation

def test.test_wsgiref.UtilityTests.checkAppURI (   self,
  uri,
  kw 
)

Definition at line 230 of file test_wsgiref.py.

00230 
00231     def checkAppURI(self,uri,**kw):
00232         util.setup_testing_defaults(kw)
00233         self.assertEqual(util.application_uri(kw),uri)

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_wsgiref.UtilityTests.checkCrossDefault (   self,
  key,
  value,
  kw 
)

Definition at line 226 of file test_wsgiref.py.

00226 
00227     def checkCrossDefault(self,key,value,**kw):
00228         util.setup_testing_defaults(kw)
00229         self.assertEqual(kw[key],value)

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_wsgiref.UtilityTests.checkDefault (   self,
  key,
  value,
  alt = None 
)

Definition at line 210 of file test_wsgiref.py.

00210 
00211     def checkDefault(self, key, value, alt=None):
00212         # Check defaulting when empty
00213         env = {}
00214         util.setup_testing_defaults(env)
00215         if isinstance(value, StringIO):
00216             self.assertIsInstance(env[key], StringIO)
00217         elif isinstance(value,BytesIO):
00218             self.assertIsInstance(env[key],BytesIO)
00219         else:
00220             self.assertEqual(env[key], value)
00221 
00222         # Check existing value
00223         env = {key:alt}
00224         util.setup_testing_defaults(env)
00225         self.assertTrue(env[key] is alt)

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_wsgiref.UtilityTests.checkFW (   self,
  text,
  size,
  match 
)

Definition at line 243 of file test_wsgiref.py.

00243 
00244     def checkFW(self,text,size,match):
00245 
00246         def make_it(text=text,size=size):
00247             return util.FileWrapper(StringIO(text),size)
00248 
00249         compare_generic_iter(make_it,match)
00250 
00251         it = make_it()
00252         self.assertFalse(it.filelike.closed)
00253 
00254         for item in it:
00255             pass
00256 
00257         self.assertFalse(it.filelike.closed)
00258 
00259         it.close()
00260         self.assertTrue(it.filelike.closed)
00261 

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_wsgiref.UtilityTests.checkReqURI (   self,
  uri,
  query = 1,
  kw 
)

Definition at line 234 of file test_wsgiref.py.

00234 
00235     def checkReqURI(self,uri,query=1,**kw):
00236         util.setup_testing_defaults(kw)
00237         self.assertEqual(util.request_uri(kw,query),uri)
00238 
00239 
00240 
00241 
00242 

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_wsgiref.UtilityTests.checkShift (   self,
  sn_in,
  pi_in,
  part,
  sn_out,
  pi_out 
)

Definition at line 202 of file test_wsgiref.py.

00202 
00203     def checkShift(self,sn_in,pi_in,part,sn_out,pi_out):
00204         env = {'SCRIPT_NAME':sn_in,'PATH_INFO':pi_in}
00205         util.setup_testing_defaults(env)
00206         self.assertEqual(util.shift_path_info(env),part)
00207         self.assertEqual(env['PATH_INFO'],pi_out)
00208         self.assertEqual(env['SCRIPT_NAME'],sn_out)
00209         return env

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 325 of file test_wsgiref.py.

00325 
00326     def testAppURIs(self):
00327         self.checkAppURI("http://127.0.0.1/")
00328         self.checkAppURI("http://127.0.0.1/spam", SCRIPT_NAME="/spam")
00329         self.checkAppURI("http://127.0.0.1/sp%C3%A4m", SCRIPT_NAME="/späm")
00330         self.checkAppURI("http://spam.example.com:2071/",
00331             HTTP_HOST="spam.example.com:2071", SERVER_PORT="2071")
00332         self.checkAppURI("http://spam.example.com/",
00333             SERVER_NAME="spam.example.com")
00334         self.checkAppURI("http://127.0.0.1/",
00335             HTTP_HOST="127.0.0.1", SERVER_NAME="spam.example.com")
00336         self.checkAppURI("https://127.0.0.1/", HTTPS="on")
00337         self.checkAppURI("http://127.0.0.1:8000/", SERVER_PORT="8000",
00338             HTTP_HOST=None)

Here is the call graph for this function:

Definition at line 304 of file test_wsgiref.py.

00304 
00305     def testCrossDefaults(self):
00306         self.checkCrossDefault('HTTP_HOST',"foo.bar",SERVER_NAME="foo.bar")
00307         self.checkCrossDefault('wsgi.url_scheme',"https",HTTPS="on")
00308         self.checkCrossDefault('wsgi.url_scheme',"https",HTTPS="1")
00309         self.checkCrossDefault('wsgi.url_scheme',"https",HTTPS="yes")
00310         self.checkCrossDefault('wsgi.url_scheme',"http",HTTPS="foo")
00311         self.checkCrossDefault('SERVER_PORT',"80",HTTPS="foo")
00312         self.checkCrossDefault('SERVER_PORT',"443",HTTPS="on")
00313 

Here is the call graph for this function:

Definition at line 284 of file test_wsgiref.py.

00284 
00285     def testDefaults(self):
00286         for key, value in [
00287             ('SERVER_NAME','127.0.0.1'),
00288             ('SERVER_PORT', '80'),
00289             ('SERVER_PROTOCOL','HTTP/1.0'),
00290             ('HTTP_HOST','127.0.0.1'),
00291             ('REQUEST_METHOD','GET'),
00292             ('SCRIPT_NAME',''),
00293             ('PATH_INFO','/'),
00294             ('wsgi.version', (1,0)),
00295             ('wsgi.run_once', 0),
00296             ('wsgi.multithread', 0),
00297             ('wsgi.multiprocess', 0),
00298             ('wsgi.input', BytesIO()),
00299             ('wsgi.errors', StringIO()),
00300             ('wsgi.url_scheme','http'),
00301         ]:
00302             self.checkDefault(key,value)
00303 

Here is the call graph for this function:

Definition at line 354 of file test_wsgiref.py.

00354 
00355     def testFileWrapper(self):
00356         self.checkFW("xyz"*50, 120, ["xyz"*40,"xyz"*10])

Here is the call graph for this function:

Definition at line 314 of file test_wsgiref.py.

00314 
00315     def testGuessScheme(self):
00316         self.assertEqual(util.guess_scheme({}), "http")
00317         self.assertEqual(util.guess_scheme({'HTTPS':"foo"}), "http")
00318         self.assertEqual(util.guess_scheme({'HTTPS':"on"}), "https")
00319         self.assertEqual(util.guess_scheme({'HTTPS':"yes"}), "https")
00320         self.assertEqual(util.guess_scheme({'HTTPS':"1"}), "https")
00321 
00322 
00323 
00324 

Here is the call graph for this function:

Definition at line 357 of file test_wsgiref.py.

00357 
00358     def testHopByHop(self):
00359         for hop in (
00360             "Connection Keep-Alive Proxy-Authenticate Proxy-Authorization "
00361             "TE Trailers Transfer-Encoding Upgrade"
00362         ).split():
00363             for alt in hop, hop.title(), hop.upper(), hop.lower():
00364                 self.assertTrue(util.is_hop_by_hop(alt))
00365 
00366         # Not comprehensive, just a few random header names
00367         for hop in (
00368             "Accept Cache-Control Date Pragma Trailer Via Warning"
00369         ).split():
00370             for alt in hop, hop.title(), hop.upper(), hop.lower():
00371                 self.assertFalse(util.is_hop_by_hop(alt))

Here is the call graph for this function:

Definition at line 270 of file test_wsgiref.py.

00270 
00271     def testNormalizedShifts(self):
00272         self.checkShift('/a/b', '/../y', '..', '/a', '/y')
00273         self.checkShift('', '/../y', '..', '', '/y')
00274         self.checkShift('/a/b', '//y', 'y', '/a/b/y', '')
00275         self.checkShift('/a/b', '//y/', 'y', '/a/b/y', '/')
00276         self.checkShift('/a/b', '/./y', 'y', '/a/b/y', '')
00277         self.checkShift('/a/b', '/./y/', 'y', '/a/b/y', '/')
00278         self.checkShift('/a/b', '///./..//y/.//', '..', '/a', '/y/')
00279         self.checkShift('/a/b', '///', '', '/a/b/', '')
00280         self.checkShift('/a/b', '/.//', '', '/a/b/', '')
00281         self.checkShift('/a/b', '/x//', 'x', '/a/b/x', '/')
00282         self.checkShift('/a/b', '/.', None, '/a/b', '')
00283 

Here is the call graph for this function:

Definition at line 339 of file test_wsgiref.py.

00339 
00340     def testReqURIs(self):
00341         self.checkReqURI("http://127.0.0.1/")
00342         self.checkReqURI("http://127.0.0.1/spam", SCRIPT_NAME="/spam")
00343         self.checkReqURI("http://127.0.0.1/sp%C3%A4m", SCRIPT_NAME="/späm")
00344         self.checkReqURI("http://127.0.0.1/spammity/spam",
00345             SCRIPT_NAME="/spammity", PATH_INFO="/spam")
00346         self.checkReqURI("http://127.0.0.1/spammity/spam;ham",
00347             SCRIPT_NAME="/spammity", PATH_INFO="/spam;ham")
00348         self.checkReqURI("http://127.0.0.1/spammity/spam;cookie=1234,5678",
00349             SCRIPT_NAME="/spammity", PATH_INFO="/spam;cookie=1234,5678")
00350         self.checkReqURI("http://127.0.0.1/spammity/spam?say=ni",
00351             SCRIPT_NAME="/spammity", PATH_INFO="/spam",QUERY_STRING="say=ni")
00352         self.checkReqURI("http://127.0.0.1/spammity/spam", 0,
00353             SCRIPT_NAME="/spammity", PATH_INFO="/spam",QUERY_STRING="say=ni")

Here is the call graph for this function:

Definition at line 262 of file test_wsgiref.py.

00262 
00263     def testSimpleShifts(self):
00264         self.checkShift('','/', '', '/', '')
00265         self.checkShift('','/x', 'x', '/x', '')
00266         self.checkShift('/','', None, '/', '')
00267         self.checkShift('/a','/x/y', 'x', '/a/x', '/y')
00268         self.checkShift('/a','/x/',  'x', '/a/x', '/')
00269 

Here is the call graph for this function:


The documentation for this class was generated from the following file: