6 class TestErrors(test_appliance
.TestAppliance
):
8 def _testErrors(self
, test_name
, invalid_filename
):
9 #self._load(invalid_filename)
10 self
.failUnlessRaises(YAMLError
, lambda: self
._load
(invalid_filename
))
12 def _testStringErrors(self
, test_name
, invalid_filename
):
13 #self._load_string(invalid_filename)
14 self
.failUnlessRaises(YAMLError
, lambda: self
._load
_string
(invalid_filename
))
16 def _load(self
, filename
):
18 reader
= Reader(file(filename
, 'rb'))
19 scanner
= Scanner(reader
)
20 parser
= Parser(scanner
)
21 composer
= Composer(parser
)
22 resolver
= Resolver(composer
)
23 constructor
= Constructor(resolver
)
24 return list(constructor
)
25 except YAMLError
, exc
:
26 #except ScannerError, exc:
27 #except ParserError, exc:
28 #except ComposerError, exc:
29 #except ConstructorError, exc:
31 #print "%s:" % exc.__class__.__name__, exc
34 def _load_string(self
, filename
):
36 reader
= Reader(file(filename
, 'rb').read())
37 scanner
= Scanner(reader
)
38 parser
= Parser(scanner
)
39 composer
= Composer(parser
)
40 resolver
= Resolver(composer
)
41 constructor
= Constructor(resolver
)
42 return list(constructor
)
43 except YAMLError
, exc
:
44 #except ScannerError, exc:
45 #except ParserError, exc:
46 #except ComposerError, exc:
47 #except ConstructorError, exc:
49 #print "%s:" % filename
50 #print "%s:" % exc.__class__.__name__, exc
53 TestErrors
.add_tests('testErrors', '.error-message')
54 TestErrors
.add_tests('testStringErrors', '.error-message')