#NEWLINE# def assert_fromfile( self , parse_func , expected_append = None , append_contents = None ) : #NEWLINE# #INDENT# def _do_assert_fromfile( dest , expected , contents ) : #NEWLINE# #INDENT# with temporary_file ( ) as fp : #NEWLINE# #INDENT# fp . write ( contents ) #NEWLINE# fp . close ( ) #NEWLINE# options = parse_func ( dest , fp . name ) #NEWLINE# self . assertEqual ( expected , options . for_scope ( 'fromfile' ) [ dest ] ) #NEWLINE# #UNINDENT# #UNINDENT# _do_assert_fromfile ( dest = 'string' , expected = 'jake' , contents = 'jake' ) #NEWLINE# _do_assert_fromfile ( dest = 'intvalue' , expected = 42 , contents = '42' ) #NEWLINE# _do_assert_fromfile ( dest = 'dictvalue' , expected = { #NEWLINE# #INDENT# 'a' : 42 , #NEWLINE# 'b' : ( 1 , 2 ) , #NEWLINE# #UNINDENT# } , contents = dedent ( "\n      {\n        'a': 42,\n        'b': (\n          1,\n          2\n        )\n      }\n      " ) ) #NEWLINE# _do_assert_fromfile ( dest = 'listvalue' , expected = [ 'a' , '1' , '2' ] , contents = dedent ( "\n      ['a',\n       1,\n       2]\n      " ) ) #NEWLINE# expected_append = ( expected_append or [ 1 , 2 , 42 ] ) #NEWLINE# append_contents = ( append_contents or dedent ( '\n      [\n       1,\n       2,\n       42\n      ]\n      ' ) ) #NEWLINE# _do_assert_fromfile ( dest = 'appendvalue' , expected = append_contents , contents = append_contents )