Back to index

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

Detailed Description

Definition at line 2501 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 2503 of file test_argparse.py.

02503 
02504     def get_parser(self, required):
02505         parser = ErrorRaisingArgumentParser(prog='PROG')
02506         parser.add_argument('-x', action='store_true', help='x help')
02507         group = parser.add_mutually_exclusive_group(required=required)
02508         group.add_argument('-a', action='store_true', help='a help')
02509         group.add_argument('-b', action='store_true', help='b help')
02510         parser.add_argument('-y', action='store_true', help='y help')
02511         group.add_argument('-c', action='store_true', help='c help')
02512         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.TestMutuallyExclusiveOptionalsMixed.failures = ['-a -b', '-b -c', '-a -c', '-a -b -c'] [static]

Definition at line 2513 of file test_argparse.py.

Initial value:
'''\

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

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

Definition at line 2514 of file test_argparse.py.

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

Definition at line 2522 of file test_argparse.py.

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

Definition at line 2528 of file test_argparse.py.


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