source: sasview/test/sasdataloader/test/error_conditions.py @ 425feff

magnetic_scattrelease-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249unittest-saveload
Last change on this file since 425feff was 959eb01, checked in by ajj, 7 years ago

normalising line endings

  • Property mode set to 100644
File size: 1.1 KB
Line 
1from sas.sascalc.dataloader.loader import Loader
2import unittest
3
4class testLoader(unittest.TestCase):
5    def setUp(self):
6        self.s = Loader()
7
8    def test_load_unknown(self):
9        """
10            self.s.load('blah.mat') on an unknown type
11            should raise a ValueError exception (thrown by data_util.registry)
12        """
13        self.assertRaises(ValueError, self.s.load, 'angles_flat.mat')
14       
15    def test_corrupt(self):
16        """
17            Loading a corrupted file with a known extension
18            should raise a runtime exception.
19            The error condition is similar to an unknown
20            type (file extension). When a reader is identified as
21            knowing the file extension, it tries to load. If it
22            raises an exception, the system should try to identify
23            another reader that knows about that file extension.
24            If they all fail, we raise a runtime exception stating
25            that no reader was found for this file.
26        """
27        self.assertRaises(RuntimeError, self.s.load, 'corrupt.png')
28
29
30if __name__ == '__main__':
31    unittest.main()
Note: See TracBrowser for help on using the repository browser.