Back to index

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

List of all members.

Public Member Functions

def assertStringEqual
def test_optional
def test_argument
def test_namespace
def test_parser
def assertEqual
def setUp

Detailed Description

Test str()  and repr() on Optionals and Positionals

Definition at line 4318 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.TestStrings.assertStringEqual (   self,
  obj,
  result_string 
)

Definition at line 4321 of file test_argparse.py.

04321 
04322     def assertStringEqual(self, obj, result_string):
04323         for func in [str, repr]:
04324             self.assertEqual(func(obj), result_string)

Here is the call graph for this function:

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 4341 of file test_argparse.py.

04341 
04342     def test_argument(self):
04343         argument = argparse.Action(
04344             option_strings=[],
04345             dest='x',
04346             type=float,
04347             nargs='?',
04348             default=2.5,
04349             choices=[0.5, 1.5, 2.5],
04350             help='H HH H',
04351             metavar='MV MV MV')
04352         string = (
04353             "Action(option_strings=[], dest='x', nargs='?', "
04354             "const=None, default=2.5, type=%r, choices=[0.5, 1.5, 2.5], "
04355             "help='H HH H', metavar='MV MV MV')" % float)
04356         self.assertStringEqual(argument, string)

Here is the call graph for this function:

Definition at line 4357 of file test_argparse.py.

04357 
04358     def test_namespace(self):
04359         ns = argparse.Namespace(foo=42, bar='spam')
04360         string = "Namespace(bar='spam', foo=42)"
04361         self.assertStringEqual(ns, string)

Here is the call graph for this function:

Definition at line 4325 of file test_argparse.py.

04325 
04326     def test_optional(self):
04327         option = argparse.Action(
04328             option_strings=['--foo', '-a', '-b'],
04329             dest='b',
04330             type='int',
04331             nargs='+',
04332             default=42,
04333             choices=[1, 2, 3],
04334             help='HELP',
04335             metavar='METAVAR')
04336         string = (
04337             "Action(option_strings=['--foo', '-a', '-b'], dest='b', "
04338             "nargs='+', const=None, default=42, type='int', "
04339             "choices=[1, 2, 3], help='HELP', metavar='METAVAR')")
04340         self.assertStringEqual(option, string)

Here is the call graph for this function:

Definition at line 4362 of file test_argparse.py.

04362 
04363     def test_parser(self):
04364         parser = argparse.ArgumentParser(prog='PROG')
04365         string = (
04366             "ArgumentParser(prog='PROG', usage=None, description=None, "
04367             "version=None, formatter_class=%r, conflict_handler='error', "
04368             "add_help=True)" % argparse.HelpFormatter)
04369         self.assertStringEqual(parser, string)
04370 
04371 # ===============
04372 # Namespace tests
04373 # ===============

Here is the call graph for this function:


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