Back to index

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

List of all members.

Public Member Functions

def test_set_defaults_no_args
def test_set_defaults_with_args
def test_set_defaults_subparsers
def test_set_defaults_parents
def test_set_defaults_same_as_add_argument
def test_set_defaults_same_as_add_argument_group
def assertEqual
def setUp

Detailed Description

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

02682 
02683     def test_set_defaults_no_args(self):
02684         parser = ErrorRaisingArgumentParser()
02685         parser.set_defaults(x='foo')
02686         parser.set_defaults(y='bar', z=1)
02687         self.assertEqual(NS(x='foo', y='bar', z=1),
02688                          parser.parse_args([]))
02689         self.assertEqual(NS(x='foo', y='bar', z=1),
02690                          parser.parse_args([], NS()))
02691         self.assertEqual(NS(x='baz', y='bar', z=1),
02692                          parser.parse_args([], NS(x='baz')))
02693         self.assertEqual(NS(x='baz', y='bar', z=2),
02694                          parser.parse_args([], NS(x='baz', z=2)))

Here is the call graph for this function:

Definition at line 2721 of file test_argparse.py.

02721 
02722     def test_set_defaults_parents(self):
02723         parent = ErrorRaisingArgumentParser(add_help=False)
02724         parent.set_defaults(x='foo')
02725         parser = ErrorRaisingArgumentParser(parents=[parent])
02726         self.assertEqual(NS(x='foo'), parser.parse_args([]))

Here is the call graph for this function:

Definition at line 2727 of file test_argparse.py.

02727 
02728     def test_set_defaults_same_as_add_argument(self):
02729         parser = ErrorRaisingArgumentParser()
02730         parser.set_defaults(w='W', x='X', y='Y', z='Z')
02731         parser.add_argument('-w')
02732         parser.add_argument('-x', default='XX')
02733         parser.add_argument('y', nargs='?')
02734         parser.add_argument('z', nargs='?', default='ZZ')
02735 
02736         # defaults set previously
02737         self.assertEqual(NS(w='W', x='XX', y='Y', z='ZZ'),
02738                          parser.parse_args([]))
02739 
02740         # reset defaults
02741         parser.set_defaults(w='WW', x='X', y='YY', z='Z')
02742         self.assertEqual(NS(w='WW', x='X', y='YY', z='Z'),
02743                          parser.parse_args([]))

Here is the call graph for this function:

Definition at line 2744 of file test_argparse.py.

02744 
02745     def test_set_defaults_same_as_add_argument_group(self):
02746         parser = ErrorRaisingArgumentParser()
02747         parser.set_defaults(w='W', x='X', y='Y', z='Z')
02748         group = parser.add_argument_group('foo')
02749         group.add_argument('-w')
02750         group.add_argument('-x', default='XX')
02751         group.add_argument('y', nargs='?')
02752         group.add_argument('z', nargs='?', default='ZZ')
02753 
02754 
02755         # defaults set previously
02756         self.assertEqual(NS(w='W', x='XX', y='Y', z='ZZ'),
02757                          parser.parse_args([]))
02758 
02759         # reset defaults
02760         parser.set_defaults(w='WW', x='X', y='YY', z='Z')
02761         self.assertEqual(NS(w='WW', x='X', y='YY', z='Z'),
02762                          parser.parse_args([]))
02763 
02764 # =================
02765 # Get default tests
02766 # =================

Here is the call graph for this function:

Definition at line 2712 of file test_argparse.py.

02712 
02713     def test_set_defaults_subparsers(self):
02714         parser = ErrorRaisingArgumentParser()
02715         parser.set_defaults(x='foo')
02716         subparsers = parser.add_subparsers()
02717         parser_a = subparsers.add_parser('a')
02718         parser_a.set_defaults(y='bar')
02719         self.assertEqual(NS(x='foo', y='bar'),
02720                          parser.parse_args('a'.split()))

Here is the call graph for this function:

Definition at line 2695 of file test_argparse.py.

02695 
02696     def test_set_defaults_with_args(self):
02697         parser = ErrorRaisingArgumentParser()
02698         parser.set_defaults(x='foo', y='bar')
02699         parser.add_argument('-x', default='xfoox')
02700         self.assertEqual(NS(x='xfoox', y='bar'),
02701                          parser.parse_args([]))
02702         self.assertEqual(NS(x='xfoox', y='bar'),
02703                          parser.parse_args([], NS()))
02704         self.assertEqual(NS(x='baz', y='bar'),
02705                          parser.parse_args([], NS(x='baz')))
02706         self.assertEqual(NS(x='1', y='bar'),
02707                          parser.parse_args('-x 1'.split()))
02708         self.assertEqual(NS(x='1', y='bar'),
02709                          parser.parse_args('-x 1'.split(), NS()))
02710         self.assertEqual(NS(x='1', y='bar'),
02711                          parser.parse_args('-x 1'.split(), NS(x='baz')))

Here is the call graph for this function:


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