Package test_suite :: Package unit_tests :: Package _lib :: Module test_timing
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._lib.test_timing

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2017 Edward d'Auvergne                                        # 
 4  #                                                                             # 
 5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
 6  #                                                                             # 
 7  # This program is free software: you can redistribute it and/or modify        # 
 8  # it under the terms of the GNU General Public License as published by        # 
 9  # the Free Software Foundation, either version 3 of the License, or           # 
10  # (at your option) any later version.                                         # 
11  #                                                                             # 
12  # This program is distributed in the hope that it will be useful,             # 
13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
15  # GNU General Public License for more details.                                # 
16  #                                                                             # 
17  # You should have received a copy of the GNU General Public License           # 
18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
19  #                                                                             # 
20  ############################################################################### 
21   
22  # Python module imports. 
23  from unittest import TestCase 
24   
25  # relax module imports. 
26  import lib.timing 
27   
28   
29 -class Test_timing(TestCase):
30 """Unit tests for the functions of the 'lib.timing' module.""" 31
33 """Test the proper behaviour of the lib.timing.print_elapsed_time() function with only seconds.""" 34 35 # Test a single value. 36 self.assertEqual("Elapsed time: 5.556 seconds\n", lib.timing.print_elapsed_time(5.555555, return_str=True))
37 38
40 """Test the proper behaviour of the lib.timing.print_elapsed_time() function with minutes.""" 41 42 # Test a single value. 43 self.assertEqual("Elapsed time: 1 minute and 5.556 seconds\n", lib.timing.print_elapsed_time(65.555555, return_str=True))
44 45
47 """Test the proper behaviour of the lib.timing.print_elapsed_time() function with minutes.""" 48 49 # Test a single value. 50 self.assertEqual("Elapsed time: 2 minutes and 5.556 seconds\n", lib.timing.print_elapsed_time(125.555555, return_str=True))
51 52
54 """Test the proper behaviour of the lib.timing.print_elapsed_time() function with minutes.""" 55 56 # Test a single value. 57 self.assertEqual("Elapsed time: 1 hour, 1 minute and 5.556 seconds\n", lib.timing.print_elapsed_time(3665.555555, return_str=True))
58 59
61 """Test the proper behaviour of the lib.timing.print_elapsed_time() function with minutes.""" 62 63 # Test a single value. 64 self.assertEqual("Elapsed time: 2 hours, 1 minute and 5.556 seconds\n", lib.timing.print_elapsed_time(7265.555555, return_str=True))
65 66
68 """Test the proper behaviour of the lib.timing.print_elapsed_time() function with minutes.""" 69 70 # Test a single value. 71 self.assertEqual("Elapsed time: 1 day, 2 hours, 2 minutes and 5.556 seconds\n", lib.timing.print_elapsed_time(93725.555555, return_str=True))
72 73
75 """Test the proper behaviour of the lib.timing.print_elapsed_time() function with minutes.""" 76 77 # Test a single value. 78 self.assertEqual("Elapsed time: 2 days, 2 hours, 2 minutes and 5.556 seconds\n", lib.timing.print_elapsed_time(180125.555555, return_str=True))
79