Parser is done. Add iterator interfaces for Scanner and Parser.
[pyyaml/python3.git] / tests / test_errors.py
blob431258b0c7a70e6429bf3ea06bf2bafad538132a
2 import test_appliance
4 from yaml.error import YAMLError
5 from yaml.reader import Reader
6 from yaml.scanner import Scanner
8 class TestErrors(test_appliance.TestAppliance):
10 def _testErrors(self, test_name, invalid_filename):
11 #self._load(invalid_filename)
12 self.failUnlessRaises(YAMLError, lambda: self._load(invalid_filename))
14 def _testStringErrors(self, test_name, invalid_filename):
15 #self._load_string(invalid_filename)
16 self.failUnlessRaises(YAMLError, lambda: self._load_string(invalid_filename))
18 def _load(self, filename):
19 reader = Reader(file(filename, 'rb'))
20 scanner = Scanner(reader)
21 return list(scanner)
23 def _load_string(self, filename):
24 reader = Reader(file(filename, 'rb').read())
25 scanner = Scanner(reader)
26 return list(scanner)
28 TestErrors.add_tests('testErrors', '.error-message')
29 TestErrors.add_tests('testStringErrors', '.error-message')