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

Revision 47, 1.0 KB checked in by xi, 9 years ago (diff)

Working on the scanner.

RevLine 
[47]1
2import test_appliance
3
4from yaml.error import YAMLError
5from yaml.reader import Reader
6from yaml.scanner import Scanner
7
8class TestErrors(test_appliance.TestAppliance):
9
10    def _testErrors(self, test_name, invalid_filename):
11        #self._load(invalid_filename)
12        self.failUnlessRaises(YAMLError, lambda: self._load(invalid_filename))
13
14    def _testStringErrors(self, test_name, invalid_filename):
15        #self._load_string(invalid_filename)
16        self.failUnlessRaises(YAMLError, lambda: self._load_string(invalid_filename))
17
18    def _load(self, filename):
19        reader = Reader(file(filename, 'rb'))
20        scanner = Scanner(reader)
21        while scanner.peek_token():
22            scanner.get_token()
23
24    def _load_string(self, filename):
25        reader = Reader(file(filename, 'rb').read())
26        scanner = Scanner(reader)
27        while scanner.peek_token():
28            scanner.get_token()
29
30TestErrors.add_tests('testErrors', '.error-message')
31TestErrors.add_tests('testStringErrors', '.error-message')
32
Note: See TracBrowser for help on using the repository browser.