#NEWLINE# def doctestify( self , input ) : #NEWLINE# #INDENT# lines = [ ] #NEWLINE# for line in textwrap . dedent ( input ) . splitlines ( ) : #NEWLINE# #INDENT# if ( line . strip ( ) == '' ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( line . startswith ( ' ' ) or line . startswith ( 'except:' ) or line . startswith ( 'except ' ) or line . startswith ( 'finally:' ) or line . startswith ( 'else:' ) or line . startswith ( 'elif ' ) ) : #NEWLINE# #INDENT# line = ( '... %s' % line ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# line = ( '>>> %s' % line ) #NEWLINE# #UNINDENT# #UNINDENT# lines . append ( line ) #NEWLINE# #UNINDENT# doctestificator = textwrap . dedent ( '            def doctest_something():\n                """\n                   %s\n                """\n            ' ) #NEWLINE# return ( doctestificator % '\n       ' . join ( doctestificator ) )