<s> import confuse <EOL> import yaml <EOL> from . import unittest , TempDir <EOL> def load ( s ) : <EOL> return yaml . load ( s , Loader = confuse . Loader ) <EOL> class ParseTest ( unittest . TestCase ) : <EOL> def test_dict_parsed_as_ordereddict ( self ) : <EOL> v = load ( "<STR_LIT>" ) <EOL> self . assertTrue ( isinstance ( v , confuse . OrderedDict ) ) <EOL> self . assertEqual ( list ( v ) , [ '<STR_LIT:a>' , '<STR_LIT:c>' ] ) <EOL> def test_string_beginning_with_percent ( self ) : <EOL> v = load ( "<STR_LIT>" ) <EOL> self . assertEqual ( v [ '<STR_LIT:foo>' ] , '<STR_LIT>' ) <EOL> class FileParseTest ( unittest . TestCase ) : <EOL> def _parse_contents ( self , contents ) : <EOL> with TempDir ( ) as temp : <EOL> path = temp . sub ( '<STR_LIT>' , contents ) <EOL> return confuse . load_yaml ( path ) <EOL> def test_load_file ( self ) : <EOL> v = self . _parse_contents ( b'<STR_LIT>' ) <EOL> self . assertEqual ( v [ '<STR_LIT:foo>' ] , '<STR_LIT:bar>' ) <EOL> def test_syntax_error ( self ) : <EOL> try : <EOL> self . _parse_contents ( b'<STR_LIT::>' ) <EOL> except confuse . ConfigError as exc : <EOL> self . assertTrue ( '<STR_LIT>' in exc . filename ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_tab_indentation_error ( self ) : <EOL> try : <EOL> self . _parse_contents ( b"<STR_LIT>" ) <EOL> except confuse . ConfigError as exc : <EOL> self . assertTrue ( '<STR_LIT>' in exc . args [ <NUM_LIT:0> ] ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) </s>
