source: branches/pyyaml3000/tests/test_errors.py @ 59

Revision 59, 1.8 KB checked in by xi, 9 years ago (diff)

Remove y/n from the boolean constants.

Line 
1
2import test_appliance
3
4from yaml import *
5
6class TestErrors(test_appliance.TestAppliance):
7
8    def _testErrors(self, test_name, invalid_filename):
9        #self._load(invalid_filename)
10        self.failUnlessRaises(YAMLError, lambda: self._load(invalid_filename))
11
12    def _testStringErrors(self, test_name, invalid_filename):
13        #self._load_string(invalid_filename)
14        self.failUnlessRaises(YAMLError, lambda: self._load_string(invalid_filename))
15
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
33
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
52
53TestErrors.add_tests('testErrors', '.error-message')
54TestErrors.add_tests('testStringErrors', '.error-message')
55
Note: See TracBrowser for help on using the repository browser.