source: sasview/test/sasdataloader/test/utest_red2d_reader.py @ 0675e6b

Last change on this file since 0675e6b was 0675e6b, checked in by Stuart Prescott <stuart@…>, 7 years ago

Fix tests to find resources without changing dir

Test resources are in the same directory (or a child directory) of the test
code so the code can locate the resources itself rather than relying on the
tests being run from a certain location. This allows the tests to be used to
test the installed code rather than the current checkout and also allows
automated test discovery with tools like py.test to be used, running all
tests at once without a runner.

  • Property mode set to 100644
File size: 1023 bytes
Line 
1"""
2    Unit tests for the red2d (3-7-column) reader
3"""
4import warnings
5warnings.simplefilter("ignore")
6
7import unittest
8from sas.sascalc.dataloader.loader import  Loader
9
10import os.path
11
12
13def find(filename):
14    return os.path.join(os.path.dirname(__file__), filename)
15
16
17class abs_reader(unittest.TestCase):
18
19    def setUp(self):
20        self.loader = Loader()
21        self.data_list = self.loader.load(find("exp18_14_igor_2dqxqy.dat"))
22
23    def test_checkdata(self):
24        """
25            Test .DAT file loaded as IGOR/DAT 2D Q_map
26        """
27        f = self.data_list[0]
28        # The length of the data is 10
29        self.assertEqual(len(self.data_list), 1)
30        self.assertEqual(len(f.qx_data),  36864)
31        self.assertEqual(f.qx_data[0],-0.03573497)
32        self.assertEqual(f.qx_data[36863],0.2908819)
33        self.assertEqual(f.Q_unit, '1/A')
34        self.assertEqual(f.I_unit, '1/cm')
35
36        self.assertEqual(f.meta_data['loader'],"IGOR/DAT 2D Q_map")
37
38
39if __name__ == '__main__':
40    unittest.main()
Note: See TracBrowser for help on using the repository browser.