source: sasview/DataLoader/test/utest_ascii.py @ 8adea21

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 8adea21 was 8adea21, checked in by Jae Cho <jhjcho@…>, 16 years ago

added one more test data

  • Property mode set to 100644
File size: 2.1 KB
Line 
1"""
2    Unit tests for the ascii (n-column) reader
3"""
4import warnings
5warnings.simplefilter("ignore")
6
7import unittest
8from DataLoader.loader import  Loader
9 
10import os.path
11
12class abs_reader(unittest.TestCase):
13   
14    def setUp(self):
15        self.loader = Loader()
16       
17    def test_checkdata(self):
18        """
19            Test .ABS file loaded as ascii
20        """
21        f = self.loader.load("ascii_test_1.txt")
22        # The length of the data is 10
23        self.assertEqual(len(f.x), 10)
24       
25    def test_truncated_1(self):
26        """
27            Test an ascii file with header and a
28            comment line in the middle of the data section.
29            The business rule says that we should stop
30            reading at the first comment once the data
31            section has started (and treat the comment
32            as though it were the start of a footer).
33        """
34        # Test .ABS file loaded as ascii
35        f = self.loader.load("ascii_test_2.txt")
36        # The length of the data is 10
37        self.assertEqual(len(f.x), 5)
38       
39    def test_truncated_2(self):
40        """
41            Test a 6-col ascii file with header and a
42            line with only 2 columns in the middle of the data section.
43            The business rule says that we should stop
44            reading at the first inconsitent line.
45        """
46        # Test .ABS file loaded as ascii
47        f = self.loader.load("ascii_test_3.txt")
48        # The length of the data is 10
49        self.assertEqual(len(f.x), 5)
50       
51    def test_truncated_3(self):
52        """
53            Test a 6-col ascii file with complex header and
54            many lines with 2 or 2 columns in the middle of the data section.
55            The business rule says that we should stop
56            reading at the last line of header.
57        """
58        # Test .ABS file loaded as ascii
59        f = self.loader.load("ascii_test_4.abs")
60        # The length of the data is 10
61        self.assertEqual(len(f.x), 5)
62       
63       
64if __name__ == '__main__':
65    unittest.main()
66   
Note: See TracBrowser for help on using the repository browser.