Loose indentation rules for the following cases:
[pyyaml/python3.git] / tests / test_errors.py
blob626b4e4148ae8a999c930e5079218768125283b5
2 import test_appliance
4 from yaml import *
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):
17 try:
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:
30 #print '.'*70
31 #print "%s:" % exc.__class__.__name__, exc
32 raise
34 def _load_string(self, filename):
35 try:
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:
48 #print '.'*70
49 #print "%s:" % filename
50 #print "%s:" % exc.__class__.__name__, exc
51 raise
53 TestErrors.add_tests('testErrors', '.error-message')
54 TestErrors.add_tests('testStringErrors', '.error-message')