Package test_suite :: Package unit_tests :: Package _prompt :: Module test_value
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._prompt.test_value

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2007-2012 Edward d'Auvergne                                   # 
 4  #                                                                             # 
 5  # This file is part of the program relax.                                     # 
 6  #                                                                             # 
 7  # relax 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 2 of the License, or           # 
10  # (at your option) any later version.                                         # 
11  #                                                                             # 
12  # relax 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 relax; if not, write to the Free Software                        # 
19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
20  #                                                                             # 
21  ############################################################################### 
22   
23  # Python module imports. 
24  from unittest import TestCase 
25   
26  # relax module imports. 
27  from prompt.value import Value 
28  from relax_errors import RelaxError, RelaxNoneNumStrListNumStrError, RelaxNoneStrError, RelaxNoneStrListStrError 
29  from test_suite.unit_tests.value_testing_base import Value_base_class 
30   
31  # Unit test imports. 
32  from data_types import DATA_TYPES 
33   
34   
35 -class Test_value(Value_base_class, TestCase):
36 """Unit tests for the functions of the 'prompt.value' module.""" 37 38 # Instantiate the user function class. 39 value_fns = Value() 40 41
42 - def test_set_argfail_val(self):
43 """The val arg test of the value.set() user function.""" 44 45 # Loop over the data types. 46 for data in DATA_TYPES: 47 # Catch the None, float, int, str, bin, float list, int list, str list, or bin list arguments, and skip them. 48 if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin' or data[0] == 'str' or data[0] == 'float' or data[0] == 'int list' or data[0] == 'bin list' or data[0] == 'str list' or data[0] == 'float list' or data[0] == 'number list': 49 continue 50 51 # The argument test. 52 self.assertRaises(RelaxNoneNumStrListNumStrError, self.value_fns.set, val=data[1], param='csa')
53 54
55 - def test_set_argfail_param(self):
56 """The param arg test of the value.set() user function.""" 57 58 # Loop over the data types. 59 for data in DATA_TYPES: 60 # Catch the None, str, and str list arguments, and skip them. 61 if data[0] == 'None' or data[0] == 'str' or data[0] == 'str list': 62 continue 63 64 # The argument test. 65 self.assertRaises(RelaxNoneStrListStrError, self.value_fns.set, param=data[1], val=None)
66 67
69 """The spin_id arg test of the value.set() user function.""" 70 71 # Loop over the data types. 72 for data in DATA_TYPES: 73 # Catch the None and str arguments, and skip them. 74 if data[0] == 'None' or data[0] == 'str': 75 continue 76 77 # The argument test. 78 self.assertRaises(RelaxNoneStrError, self.value_fns.set, spin_id=data[1])
79