source: sasview/test/sascalculator/test/utest_sas_gen.py @ f53d684

magnetic_scattrelease-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since f53d684 was f53d684, checked in by Paul Kienzle <pkienzle@…>, 7 years ago

Make tests work from any directory and functional without special runner script (#124)

  • Property mode set to 100644
File size: 1.5 KB
Line 
1"""
2Unit tests for the sas_gen
3"""
4
5import os.path
6import warnings
7warnings.simplefilter("ignore")
8
9import unittest
10from sas.sascalc.calculator import sas_gen
11
12
13def find(filename):
14    return os.path.join(os.path.dirname(__file__), filename)
15
16
17class sas_gen_test(unittest.TestCase):
18
19    def setUp(self):
20        self.sldloader = sas_gen.SLDReader()
21        self.pdbloader = sas_gen.PDBReader()
22        self.omfloader = sas_gen.OMFReader()
23
24    def test_sldreader(self):
25        """
26        Test .sld file loaded
27        """
28        f = self.sldloader.read(find("sld_file.sld"))
29        self.assertEqual(f.pos_x[0], -40.5)
30        self.assertEqual(f.pos_y[0], -13.5)
31        self.assertEqual(f.pos_z[0], -13.5)
32
33    def test_pdbreader(self):
34        """
35        Test .pdb file loaded
36        """
37        f = self.pdbloader.read(find("c60.pdb"))
38        self.assertEqual(f.pos_x[0], -0.733)
39        self.assertEqual(f.pos_y[0], -1.008)
40        self.assertEqual(f.pos_z[0], 3.326)
41
42    def test_omfreader(self):
43        """
44        Test .omf file loaded
45        """
46        f = self.omfloader.read(find("A_Raw_Example-1.omf"))
47        output = sas_gen.OMF2SLD()
48        output.set_data(f)
49        self.assertEqual(f.mx[0], 0)
50        self.assertEqual(f.my[0], 0)
51        self.assertEqual(f.mz[0], 0)
52        self.assertEqual(output.pos_x[0], 0.0)
53        self.assertEqual(output.pos_y[0], 0.0)
54        self.assertEqual(output.pos_z[0], 0.0)
55
56
57if __name__ == '__main__':
58    unittest.main()
59
Note: See TracBrowser for help on using the repository browser.