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 _testLoaderSingleErrors(self
, test_name
, invalid_filename
):
20 #self._load_single(invalid_filename)
21 self
.failUnlessRaises(YAMLError
, lambda: self
._load
_single
(invalid_filename
))
23 def _testEmitterErrors(self
, test_name
, invalid_filename
):
24 events
= list(load(file(invalid_filename
, 'rb').read(),
25 Loader
=test_emitter
.EventsLoader
))
26 self
.failUnlessRaises(YAMLError
, lambda: self
._emit
(events
))
28 def _testDumperErrors(self
, test_name
, invalid_filename
):
29 code
= file(invalid_filename
, 'rb').read()
30 self
.failUnlessRaises(YAMLError
, lambda: self
._dump
(code
))
32 def _dump(self
, code
):
35 except YAMLError
, exc
:
37 #print "%s:" % exc.__class__.__name__, exc
40 def _emit(self
, events
):
43 except YAMLError
, exc
:
45 #print "%s:" % exc.__class__.__name__, exc
48 def _load(self
, filename
):
50 return list(load_all(file(filename
, 'rb')))
51 except YAMLError
, exc
:
52 #except ScannerError, exc:
53 #except ParserError, exc:
54 #except ComposerError, exc:
55 #except ConstructorError, exc:
57 #print "%s:" % exc.__class__.__name__, exc
60 def _load_string(self
, filename
):
62 return list(load_all(file(filename
, 'rb').read()))
63 except YAMLError
, exc
:
64 #except ScannerError, exc:
65 #except ParserError, exc:
66 #except ComposerError, exc:
67 #except ConstructorError, exc:
69 #print "%s:" % filename
70 #print "%s:" % exc.__class__.__name__, exc
73 def _load_single(self
, filename
):
75 return load(file(filename
, 'rb').read())
76 except YAMLError
, exc
:
77 #except ScannerError, exc:
78 #except ParserError, exc:
79 #except ComposerError, exc:
80 #except ConstructorError, exc:
82 #print "%s:" % filename
83 #print "%s:" % exc.__class__.__name__, exc
86 TestErrors
.add_tests('testLoaderErrors', '.loader-error')
87 TestErrors
.add_tests('testLoaderStringErrors', '.loader-error')
88 TestErrors
.add_tests('testLoaderSingleErrors', '.single-loader-error')
89 TestErrors
.add_tests('testEmitterErrors', '.emitter-error')
90 TestErrors
.add_tests('testDumperErrors', '.dumper-error')