source: sasview/test/sasdataloader/test/testplugings.py @ 17c9436

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 17c9436 was 17c9436, checked in by krzywon, 7 years ago

Remove all files dynamically genereated during unit testing.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1"""
2    Unit tests for DataLoader module
3"""
4
5import os
6import unittest
7from sas.sascalc.dataloader.loader import  Loader, Registry
8class testLoader(unittest.TestCase):
9   
10    def setUp(self):
11        self.L=Loader()
12        self.L.find_plugins('../plugins')
13           
14    def testplugin(self):
15        """
16            test loading with a test reader only
17            found in the plugins directory
18        """
19        output = self.L.load('test_data.test')
20        self.assertEqual(output.x[0], 1234.)
21       
22class testRegistry(unittest.TestCase):
23   
24    def setUp(self):
25        self.L=Registry()
26        self.L.find_plugins('../plugins')
27           
28    def testplugin(self):
29        """
30            test loading with a test reader only
31            found in the plugins directory
32        """
33        output = self.L.load('test_data.test')
34        self.assertEqual(output.x[0], 1234.)
35        self.assertTrue('.test' in self.L.loaders)
36       
37class testZip(unittest.TestCase):
38   
39    def setUp(self):
40        self.L=Registry()
41       
42        # Create module
43        import zipfile
44        f_name = "plugins.zip"
45        z = zipfile.PyZipFile(f_name, 'w')
46        z.writepy("../plugins", "")
47        z.close()
48        if os.path.isfile(f_name):
49            os.remove(f_name)
50       
51    def testplugin_checksetup(self):
52        """
53            Check that the test is valid by confirming
54            that the file can't be loaded without the
55            plugins
56        """
57        self.assertRaises(ValueError, self.L.load, 'test_data.test')
58       
59    def testplugin(self):
60        """
61            test loading with a test reader only
62            found in the plugins directory
63        """
64        self.L.find_plugins('.')
65        output = self.L.load('test_data.test')
66        self.assertEqual(output.x[0], 1234.)
67        self.assertTrue('.test' in self.L.loaders)
68       
69       
70if __name__ == '__main__':
71    unittest.main()
Note: See TracBrowser for help on using the repository browser.