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
|
Rev | Line | |
---|
[1b0b3ca] | 1 | """ |
---|
| 2 | Unit tests for DataLoader module |
---|
| 3 | """ |
---|
| 4 | |
---|
| 5 | import unittest |
---|
[daa56d0] | 6 | from DataLoader.loader import Loader, Registry |
---|
[1b0b3ca] | 7 | class testLoader(unittest.TestCase): |
---|
[d3619421] | 8 | |
---|
[daa56d0] | 9 | def setUp(self): |
---|
| 10 | self.L=Loader() |
---|
| 11 | self.L.find_plugins('../plugins') |
---|
| 12 | |
---|
[1b0b3ca] | 13 | def testplugin(self): |
---|
[daa56d0] | 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.) |
---|
[2fd516b] | 20 | |
---|
[daa56d0] | 21 | class 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')) |
---|
[16d8e5f] | 35 | |
---|
[84545dd] | 36 | class 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 | |
---|
[4c00964] | 66 | if __name__ == '__main__': |
---|
| 67 | unittest.main() |
---|
Note: See
TracBrowser
for help on using the repository browser.