Back to index

python3.2  3.2.2
Classes | Functions | Variables
test.test_format Namespace Reference

Classes

class  FormatTest

Functions

def testformat
def test_main

Variables

 maxsize = support.MAX_Py_ssize_t

Function Documentation

Definition at line 266 of file test_format.py.

00266 
00267 def test_main():
00268     support.run_unittest(FormatTest)
00269 

def test.test_format.testformat (   formatstr,
  args,
  output = None,
  limit = None,
  overflowok = False 
)

Definition at line 13 of file test_format.py.

00013 
00014 def testformat(formatstr, args, output=None, limit=None, overflowok=False):
00015     if verbose:
00016         if output:
00017             print("%r %% %r =? %r ..." %\
00018                 (formatstr, args, output), end=' ')
00019         else:
00020             print("%r %% %r works? ..." % (formatstr, args), end=' ')
00021     try:
00022         result = formatstr % args
00023     except OverflowError:
00024         if not overflowok:
00025             raise
00026         if verbose:
00027             print('overflow (this is fine)')
00028     else:
00029         if output and limit is None and result != output:
00030             if verbose:
00031                 print('no')
00032             raise AssertionError("%r %% %r == %r != %r" %
00033                                 (formatstr, args, result, output))
00034         # when 'limit' is specified, it determines how many characters
00035         # must match exactly; lengths must always match.
00036         # ex: limit=5, '12345678' matches '12345___'
00037         # (mainly for floating point format tests for which an exact match
00038         # can't be guaranteed due to rounding and representation errors)
00039         elif output and limit is not None and (
00040                 len(result)!=len(output) or result[:limit]!=output[:limit]):
00041             if verbose:
00042                 print('no')
00043             print("%s %% %s == %s != %s" % \
00044                   (repr(formatstr), repr(args), repr(result), repr(output)))
00045         else:
00046             if verbose:
00047                 print('yes')
00048 

Here is the caller graph for this function:


Variable Documentation

Definition at line 6 of file test_format.py.