source: sasview/sansdataloader/test/utest_cansas.py @ 31ac4a1

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 31ac4a1 was 4bdd4fdb, checked in by Jeff Krzywon <jeffery.krzywon@…>, 12 years ago

Made good progress on new reader. Can iterate through entire tree and extract all relevant information. Next step is to put items into correct memory space.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1"""
2    Unit tests for the new recursive cansas reader
3"""
4import warnings
5warnings.simplefilter("ignore")
6
7import unittest
8from sans.dataloader.loader import  Loader
9from sans.dataloader.readers.cansas_reader_new import Reader
10
11import os
12import sys
13
14from lxml import etree
15import xml.dom.minidom
16_ZERO = 1e-16
17HAS_CONVERTER = True
18try:
19    from data_util.nxsunit import Converter
20except:
21    HAS_CONVERTER = False
22 
23CANSAS_NS = "cansas1d/1.0"   
24ALLOW_ALL = True
25   
26class cansas_reader(unittest.TestCase):
27   
28    def setUp(self):
29        self.loader = Loader()
30        self.reader = Reader()
31       
32    def test_checkdata(self):
33        output = []
34        ns = []
35        path = "cansas_test.xml"
36        if os.path.isfile(path):
37            basename = os.path.basename(path)
38            root, extension = os.path.splitext(basename)
39            if ALLOW_ALL or extension.lower() in self.ext:
40                try:
41                    tree = tree = etree.parse(path, parser=etree.ETCompatXMLParser())
42                    # Check the format version number
43                    # Specifying the namespace will take care of the file
44                    # format version
45                    for elem in tree.iter():
46                        tag = elem.tag.replace('{cansas1d/1.0}', '')
47                        print 'element: {0}, stripped element: {1}, value: {2}'.format(
48                                                                    elem.tag, tag, elem.text)
49                    # reader_return = self.reader._parse_entry(tree)
50                       
51                except Exception as e:
52                    exc_type, exc_obj, exc_tb = sys.exc_info()
53                    fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
54                    print(exc_type, fname, exc_tb.tb_lineno)
55       
56        print(output)
57       
58if __name__ == '__main__':
59    unittest.main()
Note: See TracBrowser for help on using the repository browser.