source: sasview/DataLoader/test/testplugings.py @ 479eced

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.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 479eced was 84545dd, checked in by Mathieu Doucet <doucetm@…>, 16 years ago

Added module importing from zip files.

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