Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixed Class Reference
Inheritance diagram for test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixed:
Inheritance graph
[legend]
Collaboration diagram for test.test_argparse.TestMutuallyExclusiveOptionalsAndPositionalsMixed:
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 = ['X A -b', '-b -c', '-c X A']
list successes
list successes_when_not_required
string usage_when_required
string help

Detailed Description

Definition at line 2583 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)

Definition at line 2585 of file test_argparse.py.

02585 
02586     def get_parser(self, required):
02587         parser = ErrorRaisingArgumentParser(prog='PROG')
02588         parser.add_argument('x', help='x help')
02589         parser.add_argument('-y', action='store_true', help='y help')
02590         group = parser.add_mutually_exclusive_group(required=required)
02591         group.add_argument('a', nargs='?', help='a help')
02592         group.add_argument('-b', action='store_true', help='b help')
02593         group.add_argument('-c', action='store_true', help='c help')
02594         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

Definition at line 2595 of file test_argparse.py.

Initial value:
'''\

    positional arguments:
      x           x help
      a           a help

    optional arguments:
      -h, --help  show this help message and exit
      -y          y help
      -b          b help
      -c          c help
    '''

Definition at line 2611 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:
[
        ('X A', NS(a='A', b=False, c=False, x='X', y=False)),
        ('X -b', NS(a=None, b=True, c=False, x='X', y=False)),
        ('X -c', NS(a=None, b=False, c=True, x='X', y=False)),
        ('X A -y', NS(a='A', b=False, c=False, x='X', y=True)),
        ('X -y -b', NS(a=None, b=True, c=False, x='X', y=True)),
    ]

Definition at line 2596 of file test_argparse.py.

Initial value:
[
        ('X', NS(a=None, b=False, c=False, x='X', y=False)),
        ('X -y', NS(a=None, b=False, c=False, x='X', y=True)),
    ]

Definition at line 2603 of file test_argparse.py.

Initial value:
'''\
    usage: PROG [-h] [-y] [-b] [-c] x [a]
    '''

Definition at line 2608 of file test_argparse.py.


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