source: sasview/test/sascalculator/test/utest_slit_length_calculator.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.0 KB
Line 
1"""
2    Unit tests for slit_length_calculator
3"""
4
5import os.path
6import unittest
7from sas.sascalc.dataloader.readers.ascii_reader import Reader
8from sas.sascalc.calculator.slit_length_calculator import SlitlengthCalculator \
9    as calculator
10
11
12def find(filename):
13    return os.path.join(os.path.dirname(__file__), filename)
14
15
16class SlitCalculator(unittest.TestCase):
17   
18    def setUp(self):
19       
20        self.reader = Reader()
21       
22    def test_slit_length_calculation(self):
23        """
24            Test slit_length_calculator"
25        """
26        list = self.reader.read(find("beam profile.DAT"))
27        self.assertTrue(len(list) == 1)
28        f = list[0]
29        cal = calculator()
30        cal.set_data(f.x,f.y)
31        slit_length = cal.calculate_slit_length()
32       
33        # The value "5.5858" was obtained by manual calculation.
34        # It turns out our slit length is FWHM/2
35        self.assertAlmostEqual(slit_length, 5.5858/2, 3)
36       
37       
38if __name__ == '__main__':
39    unittest.main()
40   
Note: See TracBrowser for help on using the repository browser.