Ignore:
Timestamp:
08/21/07 16:25:34 (7 years ago)
Author:
xi
Message:

Make compose() and load() ensure that the input stream contains a single document. Fixes #54.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pyyaml/trunk/tests/test_errors.py

    r146 r258  
    1616        #self._load_string(invalid_filename) 
    1717        self.failUnlessRaises(YAMLError, lambda: self._load_string(invalid_filename)) 
     18 
     19    def _testLoaderSingleErrors(self, test_name, invalid_filename): 
     20        self._load_single(invalid_filename) 
     21        self.failUnlessRaises(YAMLError, lambda: self._load_single(invalid_filename)) 
    1822 
    1923    def _testEmitterErrors(self, test_name, invalid_filename): 
     
    6771            raise 
    6872 
     73    def _load_single(self, filename): 
     74        try: 
     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: 
     81            #print '.'*70 
     82            #print "%s:" % filename 
     83            #print "%s:" % exc.__class__.__name__, exc 
     84            raise 
     85 
    6986TestErrors.add_tests('testLoaderErrors', '.loader-error') 
    7087TestErrors.add_tests('testLoaderStringErrors', '.loader-error') 
     88TestErrors.add_tests('testLoaderSingleErrors', '.single-loader-error') 
    7189TestErrors.add_tests('testEmitterErrors', '.emitter-error') 
    7290TestErrors.add_tests('testDumperErrors', '.dumper-error') 
Note: See TracChangeset for help on using the changeset viewer.