Back to index

python3.2  3.2.2
Classes | Functions | Variables
test.test_argparse Namespace Reference

Classes

class  StdIOBuffer
class  TestCase
class  TempDirMixin
class  Sig
class  NS
class  ArgumentParserError
class  ErrorRaisingArgumentParser
class  ParserTesterMetaclass
class  TestOptionalsSingleDash
class  TestOptionalsSingleDashCombined
class  TestOptionalsSingleDashLong
class  TestOptionalsSingleDashSubsetAmbiguous
class  TestOptionalsSingleDashAmbiguous
class  TestOptionalsNumeric
class  TestOptionalsDoubleDash
class  TestOptionalsDoubleDashPartialMatch
class  TestOptionalsDoubleDashPrefixMatch
class  TestOptionalsSingleDoubleDash
class  TestOptionalsAlternatePrefixChars
class  TestOptionalsAlternatePrefixCharsAddedHelp
class  TestOptionalsAlternatePrefixCharsMultipleShortArgs
class  TestOptionalsShortLong
class  TestOptionalsDest
class  TestOptionalsDefault
class  TestOptionalsNargsDefault
class  TestOptionalsNargs1
class  TestOptionalsNargs3
class  TestOptionalsNargsOptional
class  TestOptionalsNargsZeroOrMore
class  TestOptionalsNargsOneOrMore
class  TestOptionalsChoices
class  TestOptionalsRequired
class  TestOptionalsActionStore
class  TestOptionalsActionStoreConst
class  TestOptionalsActionStoreFalse
class  TestOptionalsActionStoreTrue
class  TestOptionalsActionAppend
class  TestOptionalsActionAppendWithDefault
class  TestOptionalsActionAppendConst
class  TestOptionalsActionAppendConstWithDefault
class  TestOptionalsActionCount
class  TestPositionalsNargsNone
class  TestPositionalsNargs1
class  TestPositionalsNargs2
class  TestPositionalsNargsZeroOrMore
class  TestPositionalsNargsZeroOrMoreDefault
class  TestPositionalsNargsOneOrMore
class  TestPositionalsNargsOptional
class  TestPositionalsNargsOptionalDefault
class  TestPositionalsNargsOptionalConvertedDefault
class  TestPositionalsNargsNoneNone
class  TestPositionalsNargsNone1
class  TestPositionalsNargs2None
class  TestPositionalsNargsNoneZeroOrMore
class  TestPositionalsNargsNoneOneOrMore
class  TestPositionalsNargsNoneOptional
class  TestPositionalsNargsZeroOrMoreNone
class  TestPositionalsNargsOneOrMoreNone
class  TestPositionalsNargsOptionalNone
class  TestPositionalsNargs2ZeroOrMore
class  TestPositionalsNargs2OneOrMore
class  TestPositionalsNargs2Optional
class  TestPositionalsNargsZeroOrMore1
class  TestPositionalsNargsOneOrMore1
class  TestPositionalsNargsOptional1
class  TestPositionalsNargsNoneZeroOrMore1
class  TestPositionalsNargsNoneOneOrMore1
class  TestPositionalsNargsNoneOptional1
class  TestPositionalsNargsOptionalOptional
class  TestPositionalsNargsOptionalZeroOrMore
class  TestPositionalsNargsOptionalOneOrMore
class  TestPositionalsChoicesString
class  TestPositionalsChoicesInt
class  TestPositionalsActionAppend
class  TestOptionalsNumericAndPositionals
class  TestOptionalsAlmostNumericAndPositionals
class  TestEmptyAndSpaceContainingArguments
class  TestPrefixCharacterOnlyArguments
class  TestNargsZeroOrMore
class  TestNargsRemainder
class  TestOptionLike
class  TestDefaultSuppress
class  TestParserDefaultSuppress
class  TestParserDefault42
class  TestArgumentsFromFile
class  TestArgumentsFromFileConverter
class  TestFileTypeRepr
class  RFile
class  TestFileTypeR
class  TestFileTypeRB
class  WFile
class  TestFileTypeW
class  TestFileTypeWB
class  TestTypeCallable
class  TestTypeUserDefined
class  TestTypeClassicClass
class  TestTypeRegistration
class  TestActionUserDefined
class  TestActionRegistration
class  TestAddSubparsers
class  TestPositionalsGroups
class  TestParentParsers
class  TestMutuallyExclusiveGroupErrors
class  MEMixin
class  TestMutuallyExclusiveSimple
class  TestMutuallyExclusiveLong
class  TestMutuallyExclusiveFirstSuppressed
class  TestMutuallyExclusiveManySuppressed
class  TestMutuallyExclusiveOptionalAndPositional
class  TestMutuallyExclusiveOptionalsMixed
class  TestMutuallyExclusiveInGroup
class  TestMutuallyExclusiveOptionalsAndPositionalsMixed
class  MEPBase
class  TestMutuallyExclusiveGroupErrorsParent
class  TestMutuallyExclusiveSimpleParent
class  TestMutuallyExclusiveLongParent
class  TestMutuallyExclusiveFirstSuppressedParent
class  TestMutuallyExclusiveManySuppressedParent
class  TestMutuallyExclusiveOptionalAndPositionalParent
class  TestMutuallyExclusiveOptionalsMixedParent
class  TestMutuallyExclusiveOptionalsAndPositionalsMixedParent
class  TestSetDefaults
class  TestGetDefault
class  TestNamespaceContainsSimple
class  TestHelpFormattingMetaclass
class  TestHelpBiggerOptionals
class  TestHelpBiggerOptionalGroups
class  TestHelpBiggerPositionals
class  TestHelpReformatting
class  TestHelpWrappingShortNames
class  TestHelpWrappingLongNames
class  TestHelpUsage
class  TestHelpOnlyUserGroups
class  TestHelpUsageLongProg
class  TestHelpUsageLongProgOptionsWrap
class  TestHelpUsageLongProgPositionalsWrap
class  TestHelpUsageOptionalsWrap
class  TestHelpUsagePositionalsWrap
class  TestHelpUsageOptionalsPositionalsWrap
class  TestHelpUsageOptionalsOnlyWrap
class  TestHelpUsagePositionalsOnlyWrap
class  TestHelpVariableExpansion
class  TestHelpVariableExpansionUsageSupplied
class  TestHelpVariableExpansionNoArguments
class  TestHelpSuppressUsage
class  TestHelpSuppressOptional
class  TestHelpSuppressOptionalGroup
class  TestHelpSuppressPositional
class  TestHelpRequiredOptional
class  TestHelpAlternatePrefixChars
class  TestHelpNoHelpOptional
class  TestHelpVersionOptional
class  TestHelpNone
class  TestHelpTupleMetavar
class  TestHelpRawText
class  TestHelpRawDescription
class  TestHelpArgumentDefaults
class  TestHelpVersionAction
class  TestHelpSubparsersOrdering
class  TestHelpSubparsersWithHelpOrdering
class  TestInvalidArgumentConstructors
class  TestActionsReturned
class  TestConflictHandling
class  TestOptionalsHelpVersionActions
class  TestStrings
class  TestNamespace
class  TestEncoding
class  TestArgumentError
class  TestArgumentTypeError
class  TestParseKnownArgs
class  TestAddArgumentMetavar
class  TestImportStar

Functions

def stderr_to_parser_error
def test_main

Variables

 bases = TestCase,
tuple ParserTestCase = ParserTesterMetaclass('ParserTestCase', bases, {})
tuple HelpTestCase = TestHelpFormattingMetaclass('HelpTestCase', bases, {})

Function Documentation

def test.test_argparse.stderr_to_parser_error (   parse_args,
  args,
  kwargs 
)

Definition at line 91 of file test_argparse.py.

00091 
00092 def stderr_to_parser_error(parse_args, *args, **kwargs):
00093     # if this is being called recursively and stderr or stdout is already being
00094     # redirected, simply call the function and let the enclosing function
00095     # catch the exception
00096     if isinstance(sys.stderr, StdIOBuffer) or isinstance(sys.stdout, StdIOBuffer):
00097         return parse_args(*args, **kwargs)
00098 
00099     # if this is not being called recursively, redirect stderr and
00100     # use it as the ArgumentParserError message
00101     old_stdout = sys.stdout
00102     old_stderr = sys.stderr
00103     sys.stdout = StdIOBuffer()
00104     sys.stderr = StdIOBuffer()
00105     try:
00106         try:
00107             result = parse_args(*args, **kwargs)
00108             for key in list(vars(result)):
00109                 if getattr(result, key) is sys.stdout:
00110                     setattr(result, key, old_stdout)
00111                 if getattr(result, key) is sys.stderr:
00112                     setattr(result, key, old_stderr)
00113             return result
00114         except SystemExit:
00115             code = sys.exc_info()[1].code
00116             stdout = sys.stdout.getvalue()
00117             stderr = sys.stderr.getvalue()
00118             raise ArgumentParserError("SystemExit", stdout, stderr, code)
00119     finally:
00120         sys.stdout = old_stdout
00121         sys.stderr = old_stderr
00122 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4666 of file test_argparse.py.

04666 
04667 def test_main():
04668     # silence warnings about version argument - these are expected
04669     with support.check_warnings(
04670             ('The "version" argument to ArgumentParser is deprecated.',
04671              DeprecationWarning),
04672             ('The (format|print)_version method is deprecated',
04673              DeprecationWarning)):
04674         support.run_unittest(__name__)
04675     # Remove global references to avoid looking like we have refleaks.
04676     RFile.seen = {}
04677     WFile.seen = set()
04678 
04679 

Here is the call graph for this function:


Variable Documentation

Definition at line 251 of file test_argparse.py.

Definition at line 2902 of file test_argparse.py.

Definition at line 252 of file test_argparse.py.