9 class TestErrors(test_appliance
.TestAppliance
):
11 def _testLoaderErrors(self
, test_name
, invalid_filename
):
12 #self._load(invalid_filename)
13 self
.failUnlessRaises(YAMLError
, lambda: self
._load
(invalid_filename
))
15 def _testLoaderStringErrors(self
, test_name
, invalid_filename
):
16 #self._load_string(invalid_filename)
17 self
.failUnlessRaises(YAMLError
, lambda: self
._load
_string
(invalid_filename
))
19 def _testEmitterErrors(self
, test_name
, invalid_filename
):
20 events
= list(load(file(invalid_filename
, 'rb').read(),
21 Loader
=test_emitter
.EventsLoader
))
22 self
.failUnlessRaises(YAMLError
, lambda: self
._emit
(events
))
24 def _testDumperErrors(self
, test_name
, invalid_filename
):
25 code
= file(invalid_filename
, 'rb').read()
26 self
.failUnlessRaises(YAMLError
, lambda: self
._dump
(code
))
28 def _dump(self
, code
):
31 except YAMLError
, exc
:
33 #print "%s:" % exc.__class__.__name__, exc
36 def _emit(self
, events
):
39 except YAMLError
, exc
:
41 #print "%s:" % exc.__class__.__name__, exc
44 def _load(self
, filename
):
46 return list(load_all(file(filename
, 'rb')))
47 except YAMLError
, exc
:
48 #except ScannerError, exc:
49 #except ParserError, exc:
50 #except ComposerError, exc:
51 #except ConstructorError, exc:
53 #print "%s:" % exc.__class__.__name__, exc
56 def _load_string(self
, filename
):
58 return list(load_all(file(filename
, 'rb').read()))
59 except YAMLError
, exc
:
60 #except ScannerError, exc:
61 #except ParserError, exc:
62 #except ComposerError, exc:
63 #except ConstructorError, exc:
65 #print "%s:" % filename
66 #print "%s:" % exc.__class__.__name__, exc
69 TestErrors
.add_tests('testLoaderErrors', '.loader-error')
70 TestErrors
.add_tests('testLoaderStringErrors', '.loader-error')
71 TestErrors
.add_tests('testEmitterErrors', '.emitter-error')
72 TestErrors
.add_tests('testDumperErrors', '.dumper-error')