Back to index

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

List of all members.

Public Member Functions

def test
def assertEqual
def setUp

Detailed Description

Test a user-defined type by registering it

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

01602 
01603     def test(self):
01604 
01605         def get_my_type(string):
01606             return 'my_type{%s}' % string
01607 
01608         parser = argparse.ArgumentParser()
01609         parser.register('type', 'my_type', get_my_type)
01610         parser.add_argument('-x', type='my_type')
01611         parser.add_argument('y', type='my_type')
01612 
01613         self.assertEqual(parser.parse_args('1'.split()),
01614                          NS(x=None, y='my_type{1}'))
01615         self.assertEqual(parser.parse_args('-x 1 42'.split()),
01616                          NS(x='my_type{1}', y='my_type{42}'))
01617 
01618 
01619 # ============
01620 # Action tests
01621 # ============

Here is the call graph for this function:

Here is the caller graph for this function:


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