<s> from geeknote . argparser import * <EOL> from cStringIO import StringIO <EOL> import sys <EOL> import unittest <EOL> class testArgparser ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> sys . stdout = StringIO ( ) <EOL> COMMANDS_DICT [ '<STR_LIT>' ] = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : True } , <EOL> "<STR_LIT>" : { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : None } , <EOL> "<STR_LIT>" : { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } , <EOL> } , <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:value>" : True , <EOL> "<STR_LIT:default>" : False } , <EOL> } <EOL> } <EOL> def testEmptyCommand ( self ) : <EOL> parser = argparser ( [ ] ) <EOL> self . assertFalse ( parser . parse ( ) , False ) <EOL> def testErrorCommands ( self ) : <EOL> parser = argparser ( [ "<STR_LIT>" , ] ) <EOL> self . assertFalse ( parser . parse ( ) , False ) <EOL> def testErrorArg ( self ) : <EOL> parser = argparser ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertEqual ( parser . parse ( ) , False ) <EOL> def testErrorNoArg ( self ) : <EOL> parser = argparser ( [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( parser . parse ( ) , False ) <EOL> def testErrorReq ( self ) : <EOL> parser = argparser ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertEqual ( parser . parse ( ) , False ) <EOL> def testErrorVal ( self ) : <EOL> parser = argparser ( [ "<STR_LIT>" , "<STR_LIT>" , '<STR_LIT>' ] ) <EOL> self . assertEqual ( parser . parse ( ) , False ) <EOL> def testErrorFlag ( self ) : <EOL> parser = argparser ( [ "<STR_LIT>" , "<STR_LIT>" , '<STR_LIT>' ] ) <EOL> self . assertEqual ( parser . parse ( ) , False ) <EOL> def testSuccessCommand1 ( self ) : <EOL> parser = argparser ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertEqual ( parser . parse ( ) , { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : True , <EOL> "<STR_LIT>" : "<STR_LIT>" } ) <EOL> def testSuccessCommand2 ( self ) : <EOL> parser = argparser ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertEqual ( parser . parse ( ) , { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : True , <EOL> "<STR_LIT>" : "<STR_LIT>" } ) <EOL> def testSuccessCommand3 ( self ) : <EOL> parser = argparser ( [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertEqual ( parser . parse ( ) , { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : False } ) <EOL> def testSuccessCommand4 ( self ) : <EOL> parser = argparser ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertEqual ( parser . parse ( ) , { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : None , <EOL> "<STR_LIT>" : False } ) <EOL> def testSuccessCommand5 ( self ) : <EOL> parser = argparser ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertEqual ( parser . parse ( ) , { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : None , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : False } ) <EOL> def testSuccessShortAttr ( self ) : <EOL> parser = argparser ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertEqual ( parser . parse ( ) , { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : None , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : False } ) <EOL> def testSuccessShortAttr2 ( self ) : <EOL> parser = argparser ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertEqual ( parser . parse ( ) , { "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : True } ) </s>
