<s> """<STR_LIT>""" <EOL> from twisted . trial . unittest import TestCase <EOL> from twisted . cred import credentials , error <EOL> from twisted . tap . ftp import Options <EOL> from twisted . python import versions <EOL> from twisted . python . filepath import FilePath <EOL> class FTPOptionsTests ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> usernamePassword = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> self . filename = self . mktemp ( ) <EOL> f = FilePath ( self . filename ) <EOL> f . setContent ( '<STR_LIT::>' . join ( self . usernamePassword ) ) <EOL> self . options = Options ( ) <EOL> def test_passwordfileDeprecation ( self ) : <EOL> """<STR_LIT>""" <EOL> self . callDeprecated ( <EOL> versions . Version ( "<STR_LIT>" , <NUM_LIT:11> , <NUM_LIT:1> , <NUM_LIT:0> ) , <EOL> self . options . opt_password_file , self . filename ) <EOL> def test_authAdded ( self ) : <EOL> """<STR_LIT>""" <EOL> numCheckers = len ( self . options [ '<STR_LIT>' ] ) <EOL> self . options . parseOptions ( [ '<STR_LIT>' , '<STR_LIT>' + self . filename ] ) <EOL> self . assertEqual ( len ( self . options [ '<STR_LIT>' ] ) , numCheckers + <NUM_LIT:1> ) <EOL> def test_authFailure ( self ) : <EOL> """<STR_LIT>""" <EOL> self . options . parseOptions ( [ '<STR_LIT>' , '<STR_LIT>' + self . filename ] ) <EOL> checker = self . options [ '<STR_LIT>' ] [ - <NUM_LIT:1> ] <EOL> invalid = credentials . UsernamePassword ( self . usernamePassword [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> return ( checker . requestAvatarId ( invalid ) <EOL> . addCallbacks ( <EOL> lambda ignore : self . fail ( "<STR_LIT>" ) , <EOL> lambda err : err . trap ( error . UnauthorizedLogin ) ) ) <EOL> def test_authSuccess ( self ) : <EOL> """<STR_LIT>""" <EOL> self . options . parseOptions ( [ '<STR_LIT>' , '<STR_LIT>' + self . filename ] ) <EOL> checker = self . options [ '<STR_LIT>' ] [ - <NUM_LIT:1> ] <EOL> correct = credentials . UsernamePassword ( * self . usernamePassword ) <EOL> return checker . requestAvatarId ( correct ) . addCallback ( <EOL> lambda username : self . assertEqual ( username , correct . username ) <EOL> ) </s>
