<s> """<STR_LIT>""" <EOL> from __future__ import division , absolute_import <EOL> from twisted . trial import unittest <EOL> from twisted . python import usage <EOL> class WellBehaved ( usage . Options ) : <EOL> optParameters = [ [ '<STR_LIT>' , '<STR_LIT:w>' , '<STR_LIT:default>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT:n>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , None , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , None , '<STR_LIT>' , <EOL> '<STR_LIT>' ] , <EOL> ] <EOL> optFlags = [ [ '<STR_LIT>' , '<STR_LIT:f>' , <EOL> """<STR_LIT>""" ] , <EOL> [ '<STR_LIT>' , '<STR_LIT:o>' ] , <EOL> ] <EOL> def opt_myflag ( self ) : <EOL> self . opts [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> def opt_myparam ( self , value ) : <EOL> self . opts [ '<STR_LIT>' ] = "<STR_LIT>" % ( value , ) <EOL> class ParseCorrectnessTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> self . niceArgV = ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) . split ( ) <EOL> self . nice = WellBehaved ( ) <EOL> self . nice . parseOptions ( self . niceArgV ) <EOL> def test_checkParameters ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( self . nice . opts [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> self . assertEqual ( self . nice . opts [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> self . assertEqual ( self . nice . opts [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> self . assertEqual ( self . nice . opts [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> def test_checkFlags ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( self . nice . opts [ '<STR_LIT>' ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( self . nice . opts [ '<STR_LIT>' ] , <NUM_LIT:0> ) <EOL> def test_checkCustoms ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( self . nice . opts [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> self . assertEqual ( self . nice . opts [ '<STR_LIT>' ] , "<STR_LIT>" ) <EOL> class TypedOptions ( usage . Options ) : <EOL> optParameters = [ <EOL> [ '<STR_LIT>' , None , <NUM_LIT> , '<STR_LIT>' , int ] , <EOL> [ '<STR_LIT>' , None , <NUM_LIT> , '<STR_LIT>' , float ] , <EOL> [ '<STR_LIT>' , None , None , '<STR_LIT>' , int ] , <EOL> [ '<STR_LIT>' , None , None , '<STR_LIT>' , float ] , <EOL> ] <EOL> def opt_under_score ( self , value ) : <EOL> """<STR_LIT>""" <EOL> self . underscoreValue = value <EOL> opt_u = opt_under_score <EOL> class TypedTestCase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . usage = TypedOptions ( ) <EOL> def test_defaultValues ( self ) : <EOL> """<STR_LIT>""" <EOL> argV = [ ] <EOL> self . usage . parseOptions ( argV ) <EOL> self . assertEqual ( self . usage . opts [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assert_ ( isinstance ( self . usage . opts [ '<STR_LIT>' ] , int ) ) <EOL> self . assertEqual ( self . usage . opts [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assert_ ( isinstance ( self . usage . opts [ '<STR_LIT>' ] , float ) ) <EOL> self . assertEqual ( self . usage . opts [ '<STR_LIT>' ] , None ) <EOL> self . assertEqual ( self . usage . opts [ '<STR_LIT>' ] , None ) <EOL> def test_parsingValues ( self ) : <EOL> """<STR_LIT>""" <EOL> argV = ( "<STR_LIT>" <EOL> "<STR_LIT>" ) . split ( ) <EOL> self . usage . parseOptions ( argV ) <EOL> self . assertEqual ( self . usage . opts [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assert_ ( isinstance ( self . usage . opts [ '<STR_LIT>' ] , int ) ) <EOL> self . assertEqual ( self . usage . opts [ '<STR_LIT>' ] , - <NUM_LIT> ) <EOL> self . assert_ ( isinstance ( self . usage . opts [ '<STR_LIT>' ] , float ) ) <EOL> self . assertEqual ( self . usage . opts [ '<STR_LIT>' ] , <NUM_LIT:32> ) <EOL> self . assert_ ( isinstance ( self . usage . opts [ '<STR_LIT>' ] , int ) ) <EOL> self . assertEqual ( self . usage . opts [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assert_ ( isinstance ( self . usage . opts [ '<STR_LIT>' ] , float ) ) <EOL> def test_underscoreOption ( self ) : <EOL> """<STR_LIT>""" <EOL> self . usage . parseOptions ( [ '<STR_LIT>' , '<STR_LIT:foo>' ] ) <EOL> self . assertEqual ( self . usage . underscoreValue , '<STR_LIT:foo>' ) <EOL> def test_underscoreOptionAlias ( self ) : <EOL> """<STR_LIT>""" <EOL> self . usage . parseOptions ( [ '<STR_LIT>' , '<STR_LIT:bar>' ] ) <EOL> self . assertEqual ( self . usage . underscoreValue , '<STR_LIT:bar>' ) <EOL> def test_invalidValues ( self ) : <EOL> """<STR_LIT>""" <EOL> argV = "<STR_LIT>" . split ( ) <EOL> self . assertRaises ( usage . UsageError , self . usage . parseOptions , argV ) <EOL> class WrongTypedOptions ( usage . Options ) : <EOL> optParameters = [ <EOL> [ '<STR_LIT>' , None , None , '<STR_LIT>' , '<STR_LIT>' ] <EOL> ] <EOL> class WeirdCallableOptions ( usage . Options ) : <EOL> def _bar ( value ) : <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> def _foo ( value ) : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> optParameters = [ <EOL> [ '<STR_LIT>' , None , None , '<STR_LIT>' , _bar ] , <EOL> [ '<STR_LIT>' , None , None , '<STR_LIT>' , _foo ] <EOL> ] <EOL> class WrongTypedTestCase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_nonCallable ( self ) : <EOL> """<STR_LIT>""" <EOL> us = WrongTypedOptions ( ) <EOL> argV = "<STR_LIT>" . split ( ) <EOL> self . assertRaises ( TypeError , us . parseOptions , argV ) <EOL> def test_notCalledInDefault ( self ) : <EOL> """<STR_LIT>""" <EOL> us = WeirdCallableOptions ( ) <EOL> argV = [ ] <EOL> us . parseOptions ( argV ) <EOL> def test_weirdCallable ( self ) : <EOL> """<STR_LIT>""" <EOL> us = WeirdCallableOptions ( ) <EOL> argV = "<STR_LIT>" . split ( ) <EOL> e = self . assertRaises ( usage . UsageError , us . parseOptions , argV ) <EOL> self . assertEqual ( str ( e ) , "<STR_LIT>" ) <EOL> us = WeirdCallableOptions ( ) <EOL> argV = "<STR_LIT>" . split ( ) <EOL> self . assertRaises ( RuntimeError , us . parseOptions , argV ) <EOL> class OutputTest ( unittest . TestCase ) : <EOL> def test_uppercasing ( self ) : <EOL> """<STR_LIT>""" <EOL> opt = WellBehaved ( ) <EOL> e = self . assertRaises ( usage . UsageError , <EOL> opt . parseOptions , [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( str ( e ) , '<STR_LIT>' ) <EOL> class InquisitionOptions ( usage . Options ) : <EOL> optFlags = [ <EOL> ( '<STR_LIT>' , '<STR_LIT:e>' ) , <EOL> ] <EOL> optParameters = [ <EOL> ( '<STR_LIT>' , '<STR_LIT:t>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) , <EOL> ] <EOL> class HolyQuestOptions ( usage . Options ) : <EOL> optFlags = [ ( '<STR_LIT>' , '<STR_LIT:h>' , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:g>' ) , <EOL> ] <EOL> class SubCommandOptions ( usage . Options ) : <EOL> optFlags = [ ( '<STR_LIT>' , None , <EOL> '<STR_LIT>' ) , <EOL> ] <EOL> subCommands = [ <EOL> ( '<STR_LIT>' , '<STR_LIT>' , InquisitionOptions , <EOL> '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , HolyQuestOptions , <EOL> '<STR_LIT>' ) , <EOL> ] <EOL> class SubCommandTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_simpleSubcommand ( self ) : <EOL> """<STR_LIT>""" <EOL> o = SubCommandOptions ( ) <EOL> o . parseOptions ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertEqual ( o [ '<STR_LIT>' ] , True ) <EOL> self . assertEqual ( o . subCommand , '<STR_LIT>' ) <EOL> self . failUnless ( isinstance ( o . subOptions , InquisitionOptions ) ) <EOL> self . assertEqual ( o . subOptions [ '<STR_LIT>' ] , False ) <EOL> self . assertEqual ( o . subOptions [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_subcommandWithFlagsAndOptions ( self ) : <EOL> """<STR_LIT>""" <EOL> o = SubCommandOptions ( ) <EOL> o . parseOptions ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertEqual ( o [ '<STR_LIT>' ] , False ) <EOL> self . assertEqual ( o . subCommand , '<STR_LIT>' ) <EOL> self . failUnless ( isinstance ( o . subOptions , InquisitionOptions ) ) <EOL> self . assertEqual ( o . subOptions [ '<STR_LIT>' ] , True ) <EOL> self . assertEqual ( o . subOptions [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_subcommandAliasWithFlagsAndOptions ( self ) : <EOL> """<STR_LIT>""" <EOL> o = SubCommandOptions ( ) <EOL> o . parseOptions ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertEqual ( o [ '<STR_LIT>' ] , False ) <EOL> self . assertEqual ( o . subCommand , '<STR_LIT>' ) <EOL> self . failUnless ( isinstance ( o . subOptions , InquisitionOptions ) ) <EOL> self . assertEqual ( o . subOptions [ '<STR_LIT>' ] , True ) <EOL> self . assertEqual ( o . subOptions [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_anotherSubcommandWithFlagsAndOptions ( self ) : <EOL> """<STR_LIT>""" <EOL> o = SubCommandOptions ( ) <EOL> o . parseOptions ( [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertEqual ( o [ '<STR_LIT>' ] , False ) <EOL> self . assertEqual ( o . subCommand , '<STR_LIT>' ) <EOL> self . failUnless ( isinstance ( o . subOptions , HolyQuestOptions ) ) <EOL> self . assertEqual ( o . subOptions [ '<STR_LIT>' ] , False ) <EOL> self . assertEqual ( o . subOptions [ '<STR_LIT>' ] , True ) <EOL> def test_noSubcommand ( self ) : <EOL> """<STR_LIT>""" <EOL> o = SubCommandOptions ( ) <EOL> o . parseOptions ( [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( o [ '<STR_LIT>' ] , True ) <EOL> self . assertEqual ( o . subCommand , None ) <EOL> self . failIf ( hasattr ( o , '<STR_LIT>' ) ) <EOL> def test_defaultSubcommand ( self ) : <EOL> """<STR_LIT>""" <EOL> o = SubCommandOptions ( ) <EOL> o . defaultSubCommand = '<STR_LIT>' <EOL> o . parseOptions ( [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( o [ '<STR_LIT>' ] , True ) <EOL> self . assertEqual ( o . subCommand , '<STR_LIT>' ) <EOL> self . failUnless ( isinstance ( o . subOptions , InquisitionOptions ) ) <EOL> self . assertEqual ( o . subOptions [ '<STR_LIT>' ] , False ) <EOL> self . assertEqual ( o . subOptions [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_subCommandParseOptionsHasParent ( self ) : <EOL> """<STR_LIT>""" <EOL> class SubOpt ( usage . Options ) : <EOL> def parseOptions ( self , * a , ** kw ) : <EOL> self . sawParent = self . parent <EOL> usage . Options . parseOptions ( self , * a , ** kw ) <EOL> class Opt ( usage . Options ) : <EOL> subCommands = [ <EOL> ( '<STR_LIT:foo>' , '<STR_LIT:f>' , SubOpt , '<STR_LIT:bar>' ) , <EOL> ] <EOL> o = Opt ( ) <EOL> o . parseOptions ( [ '<STR_LIT:foo>' ] ) <EOL> self . failUnless ( hasattr ( o . subOptions , '<STR_LIT>' ) ) <EOL> self . assertEqual ( o . subOptions . sawParent , o ) <EOL> def test_subCommandInTwoPlaces ( self ) : <EOL> """<STR_LIT>""" <EOL> class SubOpt ( usage . Options ) : <EOL> pass <EOL> class OptFoo ( usage . Options ) : <EOL> subCommands = [ <EOL> ( '<STR_LIT:foo>' , '<STR_LIT:f>' , SubOpt , '<STR_LIT>' ) , <EOL> ] <EOL> class OptBar ( usage . Options ) : <EOL> subCommands = [ <EOL> ( '<STR_LIT:bar>' , '<STR_LIT:b>' , SubOpt , '<STR_LIT>' ) , <EOL> ] <EOL> oFoo = OptFoo ( ) <EOL> oFoo . parseOptions ( [ '<STR_LIT:foo>' ] ) <EOL> oBar = OptBar ( ) <EOL> oBar . parseOptions ( [ '<STR_LIT:bar>' ] ) <EOL> self . failUnless ( hasattr ( oFoo . subOptions , '<STR_LIT>' ) ) <EOL> self . failUnless ( hasattr ( oBar . subOptions , '<STR_LIT>' ) ) <EOL> self . failUnlessIdentical ( oFoo . subOptions . parent , oFoo ) <EOL> self . failUnlessIdentical ( oBar . subOptions . parent , oBar ) <EOL> class HelpStringTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> self . niceArgV = ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) . split ( ) <EOL> self . nice = WellBehaved ( ) <EOL> def test_noGoBoom ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> self . nice . __str__ ( ) <EOL> except Exception as e : <EOL> self . fail ( e ) <EOL> def test_whitespaceStripFlagsAndParameters ( self ) : <EOL> """<STR_LIT>""" <EOL> lines = [ s for s in str ( self . nice ) . splitlines ( ) if s . find ( "<STR_LIT>" ) >= <NUM_LIT:0> ] <EOL> self . failUnless ( len ( lines ) > <NUM_LIT:0> ) <EOL> self . failUnless ( lines [ <NUM_LIT:0> ] . find ( "<STR_LIT>" ) >= <NUM_LIT:0> ) <EOL> class PortCoerceTestCase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_validCoerce ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <NUM_LIT:0> , usage . portCoerce ( "<STR_LIT:0>" ) ) <EOL> self . assertEqual ( <NUM_LIT> , usage . portCoerce ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( <NUM_LIT> , usage . portCoerce ( "<STR_LIT>" ) ) <EOL> def test_errorCoerce ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertRaises ( ValueError , usage . portCoerce , "<STR_LIT>" ) <EOL> self . assertRaises ( ValueError , usage . portCoerce , "<STR_LIT>" ) <EOL> self . assertRaises ( ValueError , usage . portCoerce , "<STR_LIT>" ) <EOL> self . assertRaises ( ValueError , usage . portCoerce , "<STR_LIT:foo>" ) <EOL> class ZshCompleterTestCase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_completer ( self ) : <EOL> """<STR_LIT>""" <EOL> c = usage . Completer ( ) <EOL> got = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( got , '<STR_LIT>' ) <EOL> c = usage . Completer ( descr = '<STR_LIT>' , repeat = True ) <EOL> got = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( got , '<STR_LIT>' ) <EOL> def test_files ( self ) : <EOL> """<STR_LIT>""" <EOL> c = usage . CompleteFiles ( ) <EOL> got = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( got , '<STR_LIT>' ) <EOL> c = usage . CompleteFiles ( '<STR_LIT>' ) <EOL> got = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( got , '<STR_LIT>' ) <EOL> c = usage . CompleteFiles ( '<STR_LIT>' , descr = "<STR_LIT>" , repeat = True ) <EOL> got = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( got , '<STR_LIT>' ) <EOL> def test_dirs ( self ) : <EOL> """<STR_LIT>""" <EOL> c = usage . CompleteDirs ( ) <EOL> got = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( got , '<STR_LIT>' ) <EOL> c = usage . CompleteDirs ( descr = "<STR_LIT>" , repeat = True ) <EOL> got = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( got , '<STR_LIT>' ) <EOL> def test_list ( self ) : <EOL> """<STR_LIT>""" <EOL> c = usage . CompleteList ( '<STR_LIT>' ) <EOL> got = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( got , '<STR_LIT>' ) <EOL> c = usage . CompleteList ( [ '<STR_LIT:1>' , '<STR_LIT:2>' , '<STR_LIT:3>' ] ) <EOL> got = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( got , '<STR_LIT>' ) <EOL> c = usage . CompleteList ( [ '<STR_LIT:1>' , '<STR_LIT:2>' , '<STR_LIT:3>' ] , descr = '<STR_LIT>' , <EOL> repeat = True ) <EOL> got = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( got , '<STR_LIT>' ) <EOL> def test_multiList ( self ) : <EOL> """<STR_LIT>""" <EOL> c = usage . CompleteMultiList ( '<STR_LIT>' ) <EOL> got = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( got , '<STR_LIT>' ) <EOL> c = usage . CompleteMultiList ( [ '<STR_LIT:1>' , '<STR_LIT:2>' , '<STR_LIT:3>' ] ) <EOL> got = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( got , '<STR_LIT>' ) <EOL> c = usage . CompleteMultiList ( [ '<STR_LIT:1>' , '<STR_LIT:2>' , '<STR_LIT:3>' ] , descr = '<STR_LIT>' , <EOL> repeat = True ) <EOL> got = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> expected = '<STR_LIT>' <EOL> self . assertEqual ( got , expected ) <EOL> def test_usernames ( self ) : <EOL> """<STR_LIT>""" <EOL> c = usage . CompleteUsernames ( ) <EOL> out = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( out , '<STR_LIT>' ) <EOL> c = usage . CompleteUsernames ( descr = '<STR_LIT>' , repeat = True ) <EOL> out = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( out , '<STR_LIT>' ) <EOL> def test_groups ( self ) : <EOL> """<STR_LIT>""" <EOL> c = usage . CompleteGroups ( ) <EOL> out = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( out , '<STR_LIT>' ) <EOL> c = usage . CompleteGroups ( descr = '<STR_LIT>' , repeat = True ) <EOL> out = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( out , '<STR_LIT>' ) <EOL> def test_hostnames ( self ) : <EOL> """<STR_LIT>""" <EOL> c = usage . CompleteHostnames ( ) <EOL> out = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( out , '<STR_LIT>' ) <EOL> c = usage . CompleteHostnames ( descr = '<STR_LIT>' , repeat = True ) <EOL> out = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( out , '<STR_LIT>' ) <EOL> def test_userAtHost ( self ) : <EOL> """<STR_LIT>""" <EOL> c = usage . CompleteUserAtHost ( ) <EOL> out = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertTrue ( out . startswith ( '<STR_LIT>' ) ) <EOL> c = usage . CompleteUserAtHost ( descr = '<STR_LIT>' , repeat = True ) <EOL> out = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertTrue ( out . startswith ( '<STR_LIT>' ) ) <EOL> def test_netInterfaces ( self ) : <EOL> """<STR_LIT>""" <EOL> c = usage . CompleteNetInterfaces ( ) <EOL> out = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( out , '<STR_LIT>' ) <EOL> c = usage . CompleteNetInterfaces ( descr = '<STR_LIT>' , repeat = True ) <EOL> out = c . _shellCode ( '<STR_LIT>' , usage . _ZSH ) <EOL> self . assertEqual ( out , '<STR_LIT>' ) <EOL> class CompleterNotImplementedTestCase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_unknownShell ( self ) : <EOL> """<STR_LIT>""" <EOL> classes = [ usage . Completer , usage . CompleteFiles , <EOL> usage . CompleteDirs , usage . CompleteList , <EOL> usage . CompleteMultiList , usage . CompleteUsernames , <EOL> usage . CompleteGroups , usage . CompleteHostnames , <EOL> usage . CompleteUserAtHost , usage . CompleteNetInterfaces ] <EOL> for cls in classes : <EOL> try : <EOL> action = cls ( ) <EOL> except : <EOL> action = cls ( None ) <EOL> self . assertRaises ( NotImplementedError , action . _shellCode , <EOL> None , "<STR_LIT>" ) <EOL> class FlagFunctionTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> class SomeClass ( object ) : <EOL> """<STR_LIT>""" <EOL> def oneArg ( self , a ) : <EOL> """<STR_LIT>""" <EOL> def noArg ( self ) : <EOL> """<STR_LIT>""" <EOL> def manyArgs ( self , a , b , c ) : <EOL> """<STR_LIT>""" <EOL> def test_hasArg ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertIs ( False , usage . flagFunction ( self . SomeClass ( ) . oneArg ) ) <EOL> def test_noArg ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertIs ( True , usage . flagFunction ( self . SomeClass ( ) . noArg ) ) <EOL> def test_tooManyArguments ( self ) : <EOL> """<STR_LIT>""" <EOL> exc = self . assertRaises ( <EOL> usage . UsageError , usage . flagFunction , self . SomeClass ( ) . manyArgs ) <EOL> self . assertEqual ( "<STR_LIT>" , str ( exc ) ) <EOL> def test_tooManyArgumentsAndSpecificErrorMessage ( self ) : <EOL> """<STR_LIT>""" <EOL> exc = self . assertRaises ( <EOL> usage . UsageError , <EOL> usage . flagFunction , self . SomeClass ( ) . manyArgs , "<STR_LIT>" ) <EOL> self . assertEqual ( "<STR_LIT>" , str ( exc ) ) <EOL> class OptionsInternalTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_optionsAliasesOrder ( self ) : <EOL> """<STR_LIT>""" <EOL> class Opts ( usage . Options ) : <EOL> def opt_very_very_long ( self ) : <EOL> """<STR_LIT>""" <EOL> opt_short = opt_very_very_long <EOL> opt_s = opt_very_very_long <EOL> opts = Opts ( ) <EOL> self . assertEqual ( <EOL> dict . fromkeys ( <EOL> [ "<STR_LIT:s>" , "<STR_LIT>" , "<STR_LIT>" ] , "<STR_LIT>" ) , { <EOL> "<STR_LIT:s>" : opts . synonyms [ "<STR_LIT:s>" ] , <EOL> "<STR_LIT>" : opts . synonyms [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" : opts . synonyms [ "<STR_LIT>" ] , <EOL> } ) </s>
