"Fossies" - the Fresh Open Source Software Archive

Member "fityk-1.3.1/tests/test_info.py" (13 May 2016, 1594 Bytes) of package /linux/misc/fityk-1.3.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/env python
    2 
    3 # run tests with: python -m unittest test_info
    4 #             or  python -m unittest discover
    5 
    6 import unittest
    7 import fityk
    8 
    9 class TestFormula(unittest.TestCase):
   10     def setUp(self):
   11         self.ftk = fityk.Fityk()
   12         self.ftk.set_option_as_number("verbosity", -1)
   13         self.voigt = "Voigt(926, 43.2, 0.144, 0.1)"
   14         self.splitvoigt = "SplitVoigt(926, 43.2, 0.144, 0.143, 0.1, 0.13)"
   15         self.splitvoigt_formula = ('x < 43.2 ? Voigt(926, 43.2, 0.144, 0.1) '
   16                                             ': Voigt(926, 43.2, 0.143, 0.13)')
   17     def test_voigt(self):
   18         self.ftk.execute("F = " + self.voigt)
   19         formula = self.ftk.get_info("formula")
   20         self.assertEqual(formula, self.voigt)
   21         gaussian_fwhm=self.ftk.calculate_expr
   22         f_voigt = self.ftk.get_components(0)[0]
   23         gauss_fwhm = f_voigt.get_param_value('GaussianFWHM')
   24         self.assertEqual(round(gauss_fwhm, 13), 0.2397757280134) # not verified
   25     def test_voigt_s(self):
   26         self.ftk.execute("F = " + self.voigt)
   27         formula = self.ftk.get_info("simplified_formula")
   28         self.assertEqual(formula, self.voigt)
   29     def test_splitvoigt(self):
   30         self.ftk.execute("F = " + self.splitvoigt)
   31         formula = self.ftk.get_info("formula")
   32         self.assertEqual(formula, self.splitvoigt_formula)
   33     def test_splitvoigt_s(self):
   34         self.ftk.execute("F = " + self.splitvoigt)
   35         formula = self.ftk.get_info("simplified_formula")
   36         self.assertEqual(formula, self.splitvoigt_formula)
   37 
   38 if __name__ == '__main__':
   39     unittest.main()
   40