#NEWLINE# def test_errors( self ) : #NEWLINE# #INDENT# self . assertRaises ( TypeError , pwd . getpwuid ) #NEWLINE# self . assertRaises ( TypeError , pwd . getpwnam ) #NEWLINE# self . assertRaises ( TypeError , pwd . getpwall , 42 ) #NEWLINE# bynames = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# byuids = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( n , p , u , g , gecos , d , s ) in pwd . getpwall ( ) : #NEWLINE# #INDENT# bynames [ n ] = u #NEWLINE# byuids [ u ] = n #NEWLINE# #UNINDENT# allnames = bynames . keys ( ) #NEWLINE# namei = 0 #NEWLINE# fakename = allnames [ namei ] #NEWLINE# while ( fakename in bynames ) : #NEWLINE# #INDENT# chars = list ( fakename ) #NEWLINE# for i in xrange ( len ( chars ) ) : #NEWLINE# #INDENT# if ( chars [ i ] == 'z' ) : #NEWLINE# #INDENT# chars [ i ] = 'A' #NEWLINE# break #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( chars [ i ] == 'Z' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# chars [ i ] = chr ( ( ord ( chars [ i ] ) + 1 ) ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# namei = ( namei + 1 ) #NEWLINE# try : #NEWLINE# #INDENT# fakename = allnames [ namei ] #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# fakename = '' . join ( chars ) #NEWLINE# #UNINDENT# self . assertRaises ( KeyError , pwd . getpwnam , fakename ) #NEWLINE# fakeuid = sys . maxint #NEWLINE# self . assertNotIn ( fakeuid , byuids ) #NEWLINE# self . assertRaises ( KeyError , pwd . getpwuid , fakeuid )