<s> """<STR_LIT>""" <EOL> import os <EOL> import os . path <EOL> from cStringIO import StringIO <EOL> from twisted . trial import unittest <EOL> from twisted . python import zshcomp , usage <EOL> class ZshcompTestCase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_buildAll ( self ) : <EOL> """<STR_LIT>""" <EOL> dirname = self . mktemp ( ) <EOL> os . mkdir ( dirname ) <EOL> skippedCmds = [ x [ <NUM_LIT:0> ] for x in zshcomp . makeCompFunctionFiles ( dirname ) ] <EOL> for info in zshcomp . generateFor : <EOL> if info [ <NUM_LIT:0> ] in skippedCmds : <EOL> continue <EOL> funcPath = os . path . join ( dirname , '<STR_LIT:_>' + info [ <NUM_LIT:0> ] ) <EOL> self . assertTrue ( os . path . exists ( funcPath ) ) <EOL> def test_accumulateMetadata ( self ) : <EOL> """<STR_LIT>""" <EOL> opts = FighterAceExtendedOptions ( ) <EOL> ag = zshcomp . ArgumentsGenerator ( '<STR_LIT>' , opts , '<STR_LIT>' ) <EOL> altArgDescr = FighterAceOptions . zsh_altArgDescr . copy ( ) <EOL> altArgDescr . update ( FighterAceExtendedOptions . zsh_altArgDescr ) <EOL> actionDescr = FighterAceOptions . zsh_actionDescr . copy ( ) <EOL> actionDescr . update ( FighterAceExtendedOptions . zsh_actionDescr ) <EOL> self . assertEqual ( ag . altArgDescr , altArgDescr ) <EOL> self . assertEqual ( ag . actionDescr , actionDescr ) <EOL> self . assertEqual ( ag . multiUse , FighterAceOptions . zsh_multiUse ) <EOL> self . assertEqual ( ag . mutuallyExclusive , <EOL> FighterAceOptions . zsh_mutuallyExclusive ) <EOL> self . assertEqual ( ag . actions , FighterAceOptions . zsh_actions ) <EOL> self . assertEqual ( ag . extras , FighterAceOptions . zsh_extras ) <EOL> def test_accumulateAdditionalOptions ( self ) : <EOL> """<STR_LIT>""" <EOL> opts = FighterAceExtendedOptions ( ) <EOL> ag = zshcomp . ArgumentsGenerator ( '<STR_LIT>' , opts , '<STR_LIT>' ) <EOL> self . assertIn ( '<STR_LIT>' , ag . optFlags_d ) <EOL> self . assertIn ( '<STR_LIT>' , ag . optAll_d ) <EOL> self . assertIn ( '<STR_LIT>' , ag . optParams_d ) <EOL> self . assertIn ( '<STR_LIT>' , ag . optAll_d ) <EOL> def test_verifyZshNames ( self ) : <EOL> """<STR_LIT>""" <EOL> class TmpOptions ( FighterAceExtendedOptions ) : <EOL> zsh_actions = { '<STR_LIT>' : '<STR_LIT:foo>' } <EOL> opts = TmpOptions ( ) <EOL> self . assertRaises ( ValueError , zshcomp . ArgumentsGenerator , <EOL> '<STR_LIT>' , opts , '<STR_LIT>' ) <EOL> def test_zshCode ( self ) : <EOL> """<STR_LIT>""" <EOL> cmd_name = '<STR_LIT>' <EOL> opts = SillyOptions ( ) <EOL> f = StringIO ( ) <EOL> b = zshcomp . Builder ( cmd_name , opts , f ) <EOL> b . write ( ) <EOL> f . reset ( ) <EOL> self . assertEqual ( f . read ( ) , testOutput1 ) <EOL> def test_skipBuild ( self ) : <EOL> """<STR_LIT>""" <EOL> generateFor = [ ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> skips = zshcomp . makeCompFunctionFiles ( '<STR_LIT>' , generateFor , { } ) <EOL> self . assertEqual ( len ( skips ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( skips [ <NUM_LIT:0> ] ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( skips [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> self . assertTrue ( isinstance ( skips [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , ImportError ) ) <EOL> class FighterAceOptions ( usage . Options ) : <EOL> """<STR_LIT>""" <EOL> optFlags = [ [ '<STR_LIT>' , '<STR_LIT:f>' , <EOL> '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT:a>' , <EOL> '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT:s>' , <EOL> '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT:b>' , <EOL> '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT:p>' , <EOL> '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT:v>' , <EOL> '<STR_LIT>' ] , <EOL> ] <EOL> optParameters = [ [ '<STR_LIT>' , None , "<STR_LIT>" , <EOL> '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT:d>' , <EOL> '<STR_LIT>' , '<STR_LIT:3>' ] , <EOL> ] <EOL> zsh_altArgDescr = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> zsh_actionDescr = { '<STR_LIT>' : '<STR_LIT>' } <EOL> zsh_multiUse = [ '<STR_LIT>' ] <EOL> zsh_mutuallyExclusive = [ [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ] <EOL> zsh_actions = { '<STR_LIT>' : '<STR_LIT>' } <EOL> zsh_extras = [ '<STR_LIT>' ] <EOL> class FighterAceExtendedOptions ( FighterAceOptions ) : <EOL> """<STR_LIT>""" <EOL> optFlags = [ [ '<STR_LIT>' , None , <EOL> '<STR_LIT>' ] ] <EOL> optParameters = [ [ '<STR_LIT>' , None , <EOL> '<STR_LIT>' , '<STR_LIT:5>' ] ] <EOL> zsh_altArgDescr = { '<STR_LIT>' : '<STR_LIT>' } <EOL> zsh_actionDescr = { '<STR_LIT>' : '<STR_LIT>' } <EOL> def opt_nocrash ( self ) : <EOL> """<STR_LIT>""" <EOL> def opt_difficulty ( self , difficulty ) : <EOL> """<STR_LIT>""" <EOL> def _accuracyAction ( ) : <EOL> return '<STR_LIT>' <EOL> class SillyOptions ( usage . Options ) : <EOL> """<STR_LIT>""" <EOL> optFlags = [ [ '<STR_LIT>' , '<STR_LIT:c>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT:g>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT:v>' , <EOL> '<STR_LIT>' ] , <EOL> ] <EOL> optParameters = [ [ '<STR_LIT>' , None , <EOL> '<STR_LIT>' , '<STR_LIT:5>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT:a>' , <EOL> '<STR_LIT>' , '<STR_LIT:3>' ] , <EOL> ] <EOL> zsh_altArgDescr = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> zsh_actionDescr = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> zsh_multiUse = [ '<STR_LIT>' ] <EOL> zsh_mutuallyExclusive = [ [ '<STR_LIT>' , '<STR_LIT>' ] ] <EOL> zsh_actions = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : _accuracyAction } <EOL> zsh_extras = [ '<STR_LIT>' ] <EOL> testOutput1 = """<STR_LIT>""" </s>
