Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
test.test_argparse.TestMutuallyExclusiveSimple Class Reference
Inheritance diagram for test.test_argparse.TestMutuallyExclusiveSimple:
Inheritance graph
[legend]
Collaboration diagram for test.test_argparse.TestMutuallyExclusiveSimple:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def get_parser
def test_failures_when_not_required
def test_failures_when_required
def test_successes_when_not_required
def test_successes_when_required
def test_usage_when_not_required
def test_usage_when_required
def test_help_when_not_required
def test_help_when_required
def assertEqual
def setUp

Public Attributes

_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Static Public Attributes

list failures = ['--bar X --baz Y', '--bar X --baz']
list successes
list successes_when_not_required
string usage_when_not_required
string usage_when_required
string help

Detailed Description

Definition at line 2309 of file test_argparse.py.


Member Function Documentation

def test.test_argparse.TestCase.assertEqual (   self,
  obj1,
  obj2 
) [inherited]

Definition at line 22 of file test_argparse.py.

00022 
00023     def assertEqual(self, obj1, obj2):
00024         if obj1 != obj2:
00025             print('')
00026             print(repr(obj1))
00027             print(repr(obj2))
00028             print(obj1)
00029             print(obj2)
00030         super(TestCase, self).assertEqual(obj1, obj2)

def test.test_argparse.TestMutuallyExclusiveSimple.get_parser (   self,
  required = None 
)

Definition at line 2311 of file test_argparse.py.

02311 
02312     def get_parser(self, required=None):
02313         parser = ErrorRaisingArgumentParser(prog='PROG')
02314         group = parser.add_mutually_exclusive_group(required=required)
02315         group.add_argument('--bar', help='bar help')
02316         group.add_argument('--baz', nargs='?', const='Z', help='baz help')
02317         return parser

Here is the caller graph for this function:

def test.test_argparse.TestCase.setUp (   self) [inherited]

Reimplemented in test.test_argparse.TestParentParsers, and test.test_argparse.TestAddSubparsers.

Definition at line 31 of file test_argparse.py.

00031 
00032     def setUp(self):
00033         # The tests assume that line wrapping occurs at 80 columns, but this
00034         # behaviour can be overridden by setting the COLUMNS environment
00035         # variable.  To ensure that this assumption is true, unset COLUMNS.
00036         env = support.EnvironmentVarGuard()
00037         env.unset("COLUMNS")
00038         self.addCleanup(env.__exit__)
00039 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2263 of file test_argparse.py.

02263 
02264     def test_failures_when_not_required(self):
02265         parse_args = self.get_parser(required=False).parse_args
02266         error = ArgumentParserError
02267         for args_string in self.failures:
02268             self.assertRaises(error, parse_args, args_string.split())

Here is the call graph for this function:

Definition at line 2269 of file test_argparse.py.

02269 
02270     def test_failures_when_required(self):
02271         parse_args = self.get_parser(required=True).parse_args
02272         error = ArgumentParserError
02273         for args_string in self.failures + ['']:
02274             self.assertRaises(error, parse_args, args_string.split())

Here is the call graph for this function:

Definition at line 2298 of file test_argparse.py.

02298 
02299     def test_help_when_not_required(self):
02300         format_help = self.get_parser(required=False).format_help
02301         help = self.usage_when_not_required + self.help
02302         self.assertEqual(format_help(), textwrap.dedent(help))

Here is the call graph for this function:

Definition at line 2303 of file test_argparse.py.

02303 
02304     def test_help_when_required(self):
02305         format_help = self.get_parser(required=True).format_help
02306         help = self.usage_when_required + self.help
02307         self.assertEqual(format_help(), textwrap.dedent(help))
02308 

Here is the call graph for this function:

Definition at line 2275 of file test_argparse.py.

02275 
02276     def test_successes_when_not_required(self):
02277         parse_args = self.get_parser(required=False).parse_args
02278         successes = self.successes + self.successes_when_not_required
02279         for args_string, expected_ns in successes:
02280             actual_ns = parse_args(args_string.split())
02281             self.assertEqual(actual_ns, expected_ns)

Here is the call graph for this function:

Definition at line 2282 of file test_argparse.py.

02282 
02283     def test_successes_when_required(self):
02284         parse_args = self.get_parser(required=True).parse_args
02285         for args_string, expected_ns in self.successes:
02286             actual_ns = parse_args(args_string.split())
02287             self.assertEqual(actual_ns, expected_ns)

Here is the call graph for this function:

Definition at line 2288 of file test_argparse.py.

02288 
02289     def test_usage_when_not_required(self):
02290         format_usage = self.get_parser(required=False).format_usage
02291         expected_usage = self.usage_when_not_required
02292         self.assertEqual(format_usage(), textwrap.dedent(expected_usage))

Here is the call graph for this function:

Definition at line 2293 of file test_argparse.py.

02293 
02294     def test_usage_when_required(self):
02295         format_usage = self.get_parser(required=True).format_usage
02296         expected_usage = self.usage_when_required
02297         self.assertEqual(format_usage(), textwrap.dedent(expected_usage))

Here is the call graph for this function:


Member Data Documentation

list test.test_argparse.TestMutuallyExclusiveSimple.failures = ['--bar X --baz Y', '--bar X --baz'] [static]

Definition at line 2318 of file test_argparse.py.

Initial value:
'''\

    optional arguments:
      -h, --help   show this help message and exit
      --bar BAR    bar help
      --baz [BAZ]  baz help
    '''

Definition at line 2335 of file test_argparse.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

Initial value:
[
        ('--bar X', NS(bar='X', baz=None)),
        ('--bar X --bar Z', NS(bar='Z', baz=None)),
        ('--baz Y', NS(bar=None, baz='Y')),
        ('--baz', NS(bar=None, baz='Z')),
    ]

Definition at line 2319 of file test_argparse.py.

Initial value:
[
        ('', NS(bar=None, baz=None)),
    ]

Definition at line 2325 of file test_argparse.py.

Initial value:
'''\
    usage: PROG [-h] [--bar BAR | --baz [BAZ]]
    '''

Definition at line 2329 of file test_argparse.py.

Initial value:
'''\
    usage: PROG [-h] (--bar BAR | --baz [BAZ])
    '''

Definition at line 2332 of file test_argparse.py.


The documentation for this class was generated from the following file: