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

Source Code for Module test_suite.unit_tests._lib.test_arg_check

   1  ############################################################################### 
   2  #                                                                             # 
   3  # Copyright (C) 2019 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 numpy import array, float64, int32 
  24  from re import search 
  25  import sys 
  26   
  27  # relax module imports. 
  28  from lib.arg_check import is_bool, \ 
  29          is_bool_or_bool_list, \ 
  30          is_float, \ 
  31          is_float_array, \ 
  32          is_float_matrix, \ 
  33          is_float_object, \ 
  34          is_func, \ 
  35          is_int, \ 
  36          is_int_list, \ 
  37          is_int_or_int_list, \ 
  38          is_list, \ 
  39          is_none, \ 
  40          is_num, \ 
  41          is_num_list, \ 
  42          is_num_or_num_tuple, \ 
  43          is_num_tuple, \ 
  44          is_str, \ 
  45          is_str_list, \ 
  46          is_str_or_inst, \ 
  47          is_str_or_num_or_str_num_list, \ 
  48          is_str_or_num_list, \ 
  49          is_str_or_str_list, \ 
  50          is_tuple, \ 
  51          is_val_or_list, \ 
  52          validate_arg 
  53  from lib.errors import RelaxError, \ 
  54          RelaxArrayError, \ 
  55          RelaxArrayFloatError, \ 
  56          RelaxArrayIntError, \ 
  57          RelaxArrayNumError, \ 
  58          RelaxBoolError, \ 
  59          RelaxBoolListBoolError, \ 
  60          RelaxFloatError, \ 
  61          RelaxFunctionError, \ 
  62          RelaxIntError, \ 
  63          RelaxIntListIntError, \ 
  64          RelaxInvalidError, \ 
  65          RelaxListError, \ 
  66          RelaxListBoolError, \ 
  67          RelaxListFloatError, \ 
  68          RelaxListIntError, \ 
  69          RelaxListNumError, \ 
  70          RelaxListStrError, \ 
  71          RelaxMatrixFloatError, \ 
  72          RelaxNoneBoolError, \ 
  73          RelaxNoneBoolListBoolError, \ 
  74          RelaxNoneFloatError, \ 
  75          RelaxNoneFunctionError, \ 
  76          RelaxNoneError, \ 
  77          RelaxNoneIntError, \ 
  78          RelaxNoneIntListIntError, \ 
  79          RelaxNoneListError, \ 
  80          RelaxNoneListFloatError, \ 
  81          RelaxNoneListIntError, \ 
  82          RelaxNoneListNumError, \ 
  83          RelaxNoneListStrError, \ 
  84          RelaxNoneMatrixFloatError, \ 
  85          RelaxNoneNumError, \ 
  86          RelaxNoneNumStrListNumStrError, \ 
  87          RelaxNoneNumTupleNumError, \ 
  88          RelaxNoneStrError, \ 
  89          RelaxNoneStrFileError, \ 
  90          RelaxNoneStrListNumError, \ 
  91          RelaxNoneStrListStrError, \ 
  92          RelaxNoneTupleError, \ 
  93          RelaxNoneTupleNumError, \ 
  94          RelaxNoneValListValError, \ 
  95          RelaxNumError, \ 
  96          RelaxNumStrListNumStrError, \ 
  97          RelaxNumTupleNumError, \ 
  98          RelaxNumpyFloatError, \ 
  99          RelaxNumpyIntError, \ 
 100          RelaxNumpyNumError, \ 
 101          RelaxStrError, \ 
 102          RelaxStrFileError, \ 
 103          RelaxStrFileListStrFileError, \ 
 104          RelaxStrListNumError, \ 
 105          RelaxStrListStrError, \ 
 106          RelaxTupleError, \ 
 107          RelaxTupleNumError, \ 
 108          RelaxValListValError 
 109  from test_suite.unit_tests.base_classes import UnitTestCase 
 110   
 111   
112 -def dummy_function():
113 pass
114 115
116 -class Dummy_class(object):
117 pass
118 119 120
121 -class Dummy_readable_class(object):
122 - def read(self):
123 pass
124
125 - def readline(self):
126 pass
127
128 - def readlines(self):
129 pass
130 131 132
133 -class Dummy_rw_class(object):
134 - def readable(self):
135 return True
136
137 - def writable(self):
138 return True
139 140 141
142 -class Dummy_writable_class(object):
143 - def write(self):
144 pass
145
146 - def writelines(self):
147 pass
148 149
150 -class Test_arg_check(UnitTestCase):
151 """Unit tests for the functions of the 'lib.arg_check' module.""" 152
153 - def check_function(self, func=None, allowed_types=None, dim=None, error=None, none_error=None, can_be_empty=False):
154 """Check the operation of the given function. 155 156 @keyword func: The lib.arg_check function to check. 157 @type func: func 158 @keyword allowed_types: A list of Python data type names that should result in the function returning True. 159 @type allowed_types: list of str 160 @keyword dim: The 'dim' argument used in some lib.arg_check functions. This should be a list matching the length of allowed_types. 161 @type dim: list of tuples 162 @keyword error: The expected RelaxError for a normal failure. 163 @type error: RelaxError instance 164 @keyword none_error: The expected RelaxError for a normal failure when can_be_none is set. 165 @type none_error: RelaxError instance 166 @keyword can_be_empty: Pass this argument onto the function if True. 167 @type can_be_empty: bool 168 """ 169 170 # Sanity checks. 171 if error == None: 172 raise RelaxError("The 'error' argument cannot be None.") 173 if none_error == None: 174 raise RelaxError("The 'none_error' argument cannot be None.") 175 176 # Loop over all objects. 177 for type in self.object_types: 178 # Printout to help debugging. 179 value_str = repr(self.objects[type]) 180 if search("^array", value_str): 181 value_str = value_str.replace("\n", "") 182 value_str = ''.join(value_str.split()) 183 print("Checking %s: %s" % (type, value_str)) 184 185 # None handling. 186 if type in ['none']: 187 self.assertEqual(func(self.objects[type], name=type, can_be_none=True), True) 188 self.assertRaises(error, func, self.objects[type], name=type) 189 190 # Positive tests. 191 elif type in allowed_types: 192 if dim: 193 if can_be_empty: 194 self.assertEqual(func(self.objects[type], name=type, dim=dim[allowed_types.index(type)], can_be_empty=True), True) 195 else: 196 self.assertEqual(func(self.objects[type], name=type, dim=dim[allowed_types.index(type)]), True) 197 else: 198 if can_be_empty: 199 self.assertEqual(func(self.objects[type], name=type, can_be_empty=True), True) 200 else: 201 self.assertEqual(func(self.objects[type], name=type), True) 202 203 # Negative tests. 204 else: 205 if can_be_empty: 206 self.assertEqual(func(self.objects[type], name=type, raise_error=False, can_be_empty=True), False) 207 self.assertRaises(error, func, self.objects[type], name=type, can_be_empty=True) 208 self.assertRaises(none_error, func, self.objects[type], name=type, can_be_none=True, can_be_empty=True) 209 else: 210 self.assertEqual(func(self.objects[type], name=type, raise_error=False), False) 211 self.assertRaises(error, func, self.objects[type], name=type) 212 self.assertRaises(none_error, func, self.objects[type], name=type, can_be_none=True)
213 214
215 - def check_validate_arg(self, allowed=[], none_elem=[], empty=[], error=None, dim=(), basic_types=[], container_types=[]):
216 """Check the operation of lib.arg_check.validate_arg(). 217 218 @keyword allowed: The list of Python data type names from self.objects that should result in the function returning True. 219 @type allowed: list of str 220 @keyword none_elem: The list of Python data type names from self.objects that should result in the function returning True, when 'none_elements' is set to True. 221 @type none_elem: list of str 222 @keyword empty: The list of empty Python data type names from self.objects that should result in the function returning True, when 'can_be_empty' is set to True. 223 @type empty: list of str 224 @keyword error: The expected RelaxError for a normal failure. 225 @type error: RelaxError instance 226 @keyword dim: The validate_arg() 'dim' argument. 227 @type dim: list of tuples 228 """ 229 230 # Sanity checks. 231 if error == None: 232 raise RelaxError("The 'error' argument cannot be None.") 233 234 # Loop over all objects. 235 for type in self.object_types: 236 # Printout to help debugging. 237 value_str = repr(self.objects[type]) 238 if search("^array", value_str): 239 value_str = value_str.replace("\n", "") 240 value_str = ''.join(value_str.split()) 241 242 # Allowed types. 243 if type in allowed: 244 print("Checking allowed type %s: %s" % (type, value_str)) 245 self.assertEqual(validate_arg(self.objects[type], name=type, dim=dim, basic_types=basic_types, container_types=container_types, can_be_none=False, none_elements=False), True) 246 247 # None allowed. 248 elif type in ['none']: 249 print("Checking None type %s: %s" % (type, value_str)) 250 self.assertEqual(validate_arg(self.objects[type], name=type, dim=dim, basic_types=basic_types, container_types=container_types, can_be_none=True, none_elements=False), True) 251 252 # Allowed types with None elements. 253 elif type in none_elem: 254 print("Checking allowed type with None elements %s: %s" % (type, value_str)) 255 self.assertEqual(validate_arg(self.objects[type], name=type, dim=dim, basic_types=basic_types, container_types=container_types, none_elements=True), True) 256 257 # Allowed empty types. 258 elif type in empty: 259 print("Checking allowed empty type %s: %s" % (type, value_str)) 260 self.assertEqual(validate_arg(self.objects[type], name=type, dim=dim, basic_types=basic_types, container_types=container_types, can_be_empty=True, none_elements=False), True) 261 262 # Negative tests. 263 else: 264 print("Checking disallowed type %s: %s" % (type, value_str)) 265 for can_be_empty in [True, False]: 266 for none_elements in [True, False]: 267 self.assertEqual(validate_arg(self.objects[type], name=type, dim=dim, basic_types=basic_types, container_types=container_types, can_be_empty=can_be_empty, none_elements=none_elements, raise_error=False), False) 268 self.assertRaises(error, validate_arg, self.objects[type], name=type, dim=dim, basic_types=basic_types, container_types=container_types, can_be_empty=can_be_empty, none_elements=none_elements)
269 270
271 - def setUp(self):
272 """Set up function for all tests.""" 273 274 # The objects to check. 275 self.objects = { 276 'bool': True, 277 'bool_list': [True, False], 278 'bool_tuple': (True, False), 279 'bool_none_list': [True, False, None], 280 'bool_none_tuple': (True, False, None), 281 'class': Dummy_class, 282 'empty_list': list(), 283 'empty_list_rank2': [[]], 284 'empty_list_rank3': [[[]]], 285 'empty_set': set(), 286 'empty_tuple': (), 287 'empty_tuple_rank2': ((),), 288 'empty_tuple_rank3': (((),),), 289 'file_object_list_read': [sys.__stdin__, Dummy_readable_class()], 290 'file_object_list_rw': [Dummy_rw_class()], 291 'file_object_list_write': [sys.__stdout__, Dummy_writable_class()], 292 'file_object_read': Dummy_readable_class(), 293 'file_object_rw': Dummy_rw_class(), 294 'file_object_write': sys.__stdout__, 295 'float': 1.0, 296 'float_list': [1.], 297 'float_list_rank2': [[1.]], 298 'float_list_rank3': [[[1., 2.], [3., 4.]], [[5., 6.], [7., 8.]]], 299 'float_numpy_array': array([1., 2.], float64), 300 'float_numpy_array_empty': array([], float64), 301 'float_numpy_matrix': array([[1., 2.], [3., 4.]], float64), 302 'float_numpy_matrix_empty': array([[]], float64), 303 'float_numpy_object': array([[[1., 2.], [3., 4.]], [[5., 6.], [7., 8.]]], float64), 304 'float_numpy_object_empty': array([[[]]], float64), 305 'float_set': set([1., 2.]), 306 'float_tuple': (1., 2.), 307 'float_tuple_rank2': ((1., 2.), (3., 4.)), 308 'float_tuple_rank3': (((1., 2.), (3., 4.)), ((5., 6.), (7., 8.))), 309 'float_none_list': [1., None], 310 'float_none_list_rank2': [[1., None]], 311 'float_none_list_rank3': [[[1., 2.], [3., 4.]], [[5., 6.], [7., None]]], 312 'float_none_set': set([1., 2., None]), 313 'float_none_tuple': (1., 2., None), 314 'float_none_tuple_rank2': ((1., 2.), (3., None)), 315 'float_none_tuple_rank3': (((1., 2.), (3., 4.)), ((5., 6.), (7., None))), 316 'func': dummy_function, 317 'int': 2, 318 'int_list': [1, 2], 319 'int_list_rank2': [[1, 2], [3, 4]], 320 'int_list_rank3': [[[1, 2], [3, 4]], [[5, 6], [7, 8]]], 321 'int_numpy_array': array([1, 2], int32), 322 'int_numpy_array_empty': array([], int32), 323 'int_numpy_matrix': array([[1, 2], [3, 4]], int32), 324 'int_numpy_matrix_empty': array([[]], int32), 325 'int_numpy_object': array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]], int32), 326 'int_numpy_object_empty': array([[[]]], int32), 327 'int_set': set([1, 2]), 328 'int_tuple': (1, 2), 329 'int_tuple_rank2': ((1, 2), (3, 4)), 330 'int_tuple_rank3': (((1, 2), (3, 4)), ((5, 6), (7, 8))), 331 'int_none_list': [1, None], 332 'int_none_list_rank2': [[1, 2], [3, None]], 333 'int_none_list_rank3': [[[1, 2], [3, 4]], [[5, 6], [7, None]]], 334 'int_none_tuple': (1, None), 335 'int_none_tuple_rank2': ((1, 2), (3, None)), 336 'int_none_tuple_rank3': (((1, 2), (3, 4)), ((5, 6), (7, None))), 337 'int_none_set': set([1, 2, None]), 338 'inst': Dummy_class(), 339 'inst_file': Dummy_writable_class(), 340 'none': None, 341 'str': 'test', 342 'str_list': ['test'], 343 'str_list_rank2': [['test']], 344 'str_num_list': [1, 'test'], 345 'str_set': set(['test']), 346 'str_tuple': ('test',), 347 'str_tuple_rank2': (('test1', 'test2'), ('test3', 'test4')), 348 'str_tuple_rank3': ((('test1', 'test2'), ('test3', 'test4')), (('test5', 'test6'), ('test7', 'test8'))), 349 'str_none_list': ['test', None], 350 'str_none_list_rank2': [['test', None]], 351 'str_none_num_list': [1, 'test', None], 352 'str_none_set': set(['test', None]), 353 'str_none_tuple': ('test', None), 354 'str_none_tuple_rank2': (('test1', 'test2'), ('test3', None)), 355 'str_none_tuple_rank3': ((('test1', 'test2'), ('test3', 'test4')), (('test5', 'test6'), ('test7', None))), 356 } 357 self.object_types = list(self.objects.keys()) 358 self.object_types.sort()
359 360
361 - def test_is_bool(self):
362 """Test the lib.arg_check.is_bool() function.""" 363 364 self.check_function(func=is_bool, allowed_types=['bool'], error=RelaxBoolError, none_error=RelaxNoneBoolError)
365 366
367 - def test_is_bool_or_bool_list(self):
368 """Test the lib.arg_check.is_bool_or_bool_list() function.""" 369 370 self.check_function(func=is_bool_or_bool_list, allowed_types=['bool', 'bool_list'], error=RelaxBoolListBoolError, none_error=RelaxNoneBoolListBoolError)
371 372
373 - def test_is_float(self):
374 """Test the lib.arg_check.is_float() function.""" 375 376 self.check_function(func=is_float, allowed_types=['float'], error=RelaxFloatError, none_error=RelaxNoneFloatError)
377 378
379 - def test_is_float_array(self):
380 """Test the lib.arg_check.is_float_array() function.""" 381 382 self.check_function(func=is_float_array, allowed_types=['empty_list', 'float_numpy_array', 'float_numpy_array_empty', 'float_list'], error=RelaxListFloatError, none_error=RelaxNoneListFloatError)
383 384
385 - def test_is_float_matrix(self):
386 """Test the lib.arg_check.is_float_matrix() function.""" 387 388 self.check_function(func=is_float_matrix, allowed_types=['empty_list_rank2', 'float_list_rank2', 'float_numpy_matrix', 'float_numpy_matrix_empty'], error=RelaxMatrixFloatError, none_error=RelaxNoneMatrixFloatError)
389 390
391 - def test_is_float_object(self):
392 """Test the lib.arg_check.is_float_object() function.""" 393 394 self.check_function(func=is_float_object, allowed_types=['float_list', 'float_list_rank2', 'float_list_rank3', 'float_numpy_array', 'float_numpy_array_empty', 'float_numpy_matrix', 'float_numpy_object'], dim=[(1,), (1, 1), (2,2,2), (2,), (0,), (2,2), (2,2,2)], error=RelaxListFloatError, none_error=RelaxNoneListFloatError)
395 396
397 - def test_is_func(self):
398 """Test the lib.arg_check.is_func() function.""" 399 400 self.check_function(func=is_func, allowed_types=['func'], error=RelaxFunctionError, none_error=RelaxNoneFunctionError)
401 402
403 - def test_is_int(self):
404 """Test the lib.arg_check.is_int() function.""" 405 406 self.check_function(func=is_int, allowed_types=['int'], error=RelaxIntError, none_error=RelaxNoneIntError)
407 408
409 - def test_is_int_list(self):
410 """Test the lib.arg_check.is_int_list() function.""" 411 412 self.check_function(func=is_int_list, allowed_types=['int_list'], error=RelaxListIntError, none_error=RelaxNoneListIntError)
413 414
415 - def test_is_int_or_int_list(self):
416 """Test the lib.arg_check.is_int_or_int_list() function.""" 417 418 self.check_function(func=is_int_or_int_list, allowed_types=['int', 'int_list' ], error=RelaxIntListIntError, none_error=RelaxNoneIntListIntError)
419 420
421 - def test_is_list(self):
422 """Test the lib.arg_check.is_list() function.""" 423 424 allowed_types = [ 425 'bool_list', 426 'bool_none_list', 427 'empty_list_rank2', 428 'empty_list_rank3', 429 'file_object_list_read', 430 'file_object_list_rw', 431 'file_object_list_write', 432 'float_list', 433 'float_list_rank2', 434 'float_list_rank3', 435 'float_none_list', 436 'float_none_list_rank2', 437 'float_none_list_rank3', 438 'int_list', 439 'int_list_rank2', 440 'int_list_rank3', 441 'int_none_list', 442 'int_none_list_rank2', 443 'int_none_list_rank3', 444 'str_list', 445 'str_list_rank2', 446 'str_num_list', 447 'str_none_list', 448 'str_none_list_rank2', 449 'str_none_num_list' 450 ] 451 self.check_function(func=is_list, allowed_types=['empty_list']+allowed_types, error=RelaxListError, none_error=RelaxNoneListError, can_be_empty=True) 452 self.check_function(func=is_list, allowed_types=allowed_types, error=RelaxListError, none_error=RelaxNoneListError, can_be_empty=False)
453 454
455 - def test_is_none(self):
456 """Test the lib.arg_check.is_none() function.""" 457 458 # Loop over all objects. 459 for type in self.object_types: 460 if type in ['none']: 461 self.assertEqual(is_none(self.objects[type], name=type), True) 462 else: 463 self.assertRaises(RelaxNoneError, is_none, self.objects[type], name=type)
464 465
466 - def test_is_num(self):
467 """Test the lib.arg_check.is_num() function.""" 468 469 self.check_function(func=is_num, allowed_types=['float', 'int'], error=RelaxNumError, none_error=RelaxNoneNumError)
470 471
472 - def test_is_num_list(self):
473 """Test the lib.arg_check.is_num_list() function.""" 474 475 self.check_function(func=is_num_list, allowed_types=['float_list', 'float_numpy_array', 'int_list', 'int_numpy_array'], error=RelaxListNumError, none_error=RelaxNoneListNumError)
476 477
478 - def test_is_num_or_num_tuple(self):
479 """Test the lib.arg_check.is_num_or_num_tuple() function.""" 480 481 self.check_function(func=is_num_or_num_tuple, allowed_types=['float', 'float_tuple', 'int', 'int_tuple'], error=RelaxNumTupleNumError, none_error=RelaxNoneNumTupleNumError)
482 483
484 - def test_is_num_tuple(self):
485 """Test the lib.arg_check.is_num_tuple() function.""" 486 487 self.check_function(func=is_num_tuple, allowed_types=['float_tuple', 'int_tuple'], error=RelaxTupleNumError, none_error=RelaxNoneTupleNumError)
488 489
490 - def test_is_str(self):
491 """Test the lib.arg_check.is_str() function.""" 492 493 self.check_function(func=is_str, allowed_types=['str'], error=RelaxStrError, none_error=RelaxNoneStrError)
494 495
496 - def test_is_str_list(self):
497 """Test the lib.arg_check.is_str_list() function.""" 498 499 self.check_function(func=is_str_list, allowed_types=['str_list'], error=RelaxListStrError, none_error=RelaxNoneListStrError)
500 501
502 - def test_is_str_or_inst(self):
503 """Test the lib.arg_check.is_str_or_inst() function.""" 504 505 self.check_function(func=is_str_or_inst, allowed_types=['str', 'file_object_write', 'inst_file'], error=RelaxStrFileError, none_error=RelaxNoneStrFileError)
506 507
509 """Test the lib.arg_check.is_str_or_num_or_str_num_list() function.""" 510 511 self.check_function(func=is_str_or_num_or_str_num_list, allowed_types=['float', 'float_list', 'int', 'int_list', 'str', 'str_list', 'str_num_list'], error=RelaxNumStrListNumStrError, none_error=RelaxNoneNumStrListNumStrError)
512 513
514 - def test_is_str_or_num_list(self):
515 """Test the lib.arg_check.is_str_or_num_list() function.""" 516 517 self.check_function(func=is_str_or_num_list, allowed_types=['float_list', 'int_list', 'str'], error=RelaxStrListNumError, none_error=RelaxNoneStrListNumError)
518 519
520 - def test_is_str_or_str_list(self):
521 """Test the lib.arg_check.is_str_or_str_list() function.""" 522 523 self.check_function(func=is_str_or_str_list, allowed_types=['str', 'str_list'], error=RelaxStrListStrError, none_error=RelaxNoneStrListStrError)
524 525
526 - def test_is_tuple(self):
527 """Test the lib.arg_check.is_tuple() function.""" 528 529 allowed_types = [ 530 'bool_tuple', 531 'bool_none_tuple', 532 'empty_tuple', 533 'empty_tuple_rank2', 534 'empty_tuple_rank3', 535 'float_tuple', 536 'float_tuple_rank2', 537 'float_tuple_rank3', 538 'float_none_tuple', 539 'float_none_tuple_rank2', 540 'float_none_tuple_rank3', 541 'int_tuple', 542 'int_tuple_rank2', 543 'int_tuple_rank3', 544 'int_none_tuple', 545 'int_none_tuple_rank2', 546 'int_none_tuple_rank3', 547 'str_tuple', 548 'str_tuple_rank2', 549 'str_tuple_rank3', 550 'str_none_tuple', 551 'str_none_tuple_rank2', 552 'str_none_tuple_rank3' 553 ] 554 self.check_function(func=is_tuple, allowed_types=allowed_types, error=RelaxTupleError, none_error=RelaxNoneTupleError)
555 556
557 - def test_is_val_or_list(self):
558 """Test the lib.arg_check.is_val_or_list() function.""" 559 560 self.check_function(func=is_val_or_list, allowed_types=['bool', 'bool_list', 'float', 'float_list', 'int', 'int_list', 'str', 'str_list', 'str_num_list'], error=RelaxValListValError, none_error=RelaxNoneValListValError)
561 562
564 """Test lib.arg_check.validate_arg() with basic data type-checking off.""" 565 566 # The allowed types. 567 allowed = [ 568 'bool', 569 'class', 570 'file_object_read', 571 'file_object_rw', 572 'file_object_write', 573 'float', 574 'func', 575 'int', 576 'inst', 577 'inst_file', 578 'str' 579 ] 580 581 # Checks. 582 self.check_validate_arg(allowed=allowed, error=RelaxInvalidError, basic_types=['all'])
583 584
586 """Test lib.arg_check.validate_arg() with container type-checking off.""" 587 588 self.check_validate_arg(allowed=self.object_types, error=RelaxInvalidError, basic_types=['all'], container_types=['all'])
589 590
592 """Test lib.arg_check.validate_arg() with all type-checking off.""" 593 594 self.check_validate_arg(allowed=self.object_types, error=RelaxInvalidError, basic_types=['all'], container_types=['all'])
595 596
597 - def test_validate_arg_bool(self):
598 """Test lib.arg_check.validate_arg() for a basic Boolean type.""" 599 600 # The allowed types. 601 allowed = [ 602 'bool', 603 ] 604 605 # Checks. 606 self.check_validate_arg(allowed=allowed, error=RelaxBoolError, dim=(), basic_types=['bool'])
607 608
610 """Test lib.arg_check.validate_arg() for a list of Booleans.""" 611 612 # The allowed types. 613 allowed = [ 614 'bool_list', 615 ] 616 none_elem = [ 617 'bool_none_list', 618 ] 619 empty = [ 620 'empty_list', 621 ] 622 623 # Checks. 624 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxListBoolError, dim=(None,), basic_types=['bool'], container_types=['list']) 625 self.check_validate_arg(allowed=[], none_elem=[], error=RelaxListBoolError, dim=(5,), basic_types=['bool'], container_types=['list'])
626 627
629 """Test lib.arg_check.validate_arg() for a list of lists of Booleans.""" 630 631 # The allowed types. 632 allowed = [ 633 'bool_list_rank2', 634 ] 635 none_elem = [ 636 'bool_none_list_rank2', 637 ] 638 empty = [ 639 'empty_list_rank2', 640 ] 641 642 # Checks. 643 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxInvalidError, dim=(None,None), basic_types=['bool'], container_types=['list'])
644 645
647 """Test lib.arg_check.validate_arg() for a Boolean or a list of Booleans.""" 648 649 # The allowed types. 650 allowed = [ 651 'bool', 652 'bool_list', 653 ] 654 none_elem = [ 655 'bool_none_list', 656 ] 657 empty = [ 658 'empty_list', 659 ] 660 661 # Checks. 662 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxBoolListBoolError, dim=[(), (None,)], basic_types=['bool'], container_types=['list'])
663 664
665 - def test_validate_arg_float(self):
666 """Test lib.arg_check.validate_arg() for a basic float type.""" 667 668 # The allowed types. 669 allowed = [ 670 'float', 671 ] 672 673 # Checks. 674 self.check_validate_arg(allowed=allowed, error=RelaxFloatError, dim=(), basic_types=['float'])
675 676
678 """Test lib.arg_check.validate_arg() for a list of floats.""" 679 680 # The allowed types. 681 allowed = [ 682 'float_list', 683 ] 684 none_elem = [ 685 'float_none_list', 686 ] 687 empty = [ 688 'empty_list', 689 ] 690 691 # Checks. 692 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxListFloatError, dim=(None,), basic_types=['float'], container_types=['list'])
693 694
696 """Test lib.arg_check.validate_arg() for a list of lists of floats.""" 697 698 # The allowed types. 699 allowed = [ 700 'float_list_rank2', 701 ] 702 none_elem = [ 703 'float_none_list_rank2', 704 ] 705 empty = [ 706 'empty_list_rank2', 707 ] 708 709 # Checks. 710 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxInvalidError, dim=(None,None), basic_types=['float'], container_types=['list'])
711 712
714 """Test lib.arg_check.validate_arg() for a float or list of floats.""" 715 716 # The allowed types. 717 allowed = [ 718 'float', 719 'float_list', 720 ] 721 none_elem = [ 722 'float_none_list', 723 ] 724 empty = [ 725 'empty_list', 726 ] 727 728 # Checks. 729 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxInvalidError, dim=[(), (None,)], basic_types=['float'], container_types=['list'])
730 731
732 - def test_validate_arg_func(self):
733 """Test lib.arg_check.validate_arg() for a basic function type.""" 734 735 # The allowed types. 736 allowed = [ 737 'func', 738 ] 739 740 # Checks. 741 self.check_validate_arg(allowed=allowed, error=RelaxFunctionError, dim=(), basic_types=['func'])
742 743
744 - def test_validate_arg_int(self):
745 """Test lib.arg_check.validate_arg() for a basic integer type.""" 746 747 # The allowed types. 748 allowed = [ 749 'int', 750 ] 751 752 # Checks. 753 self.check_validate_arg(allowed=allowed, error=RelaxIntError, dim=(), basic_types=['int'])
754 755
756 - def test_validate_arg_int_list(self):
757 """Test lib.arg_check.validate_arg() for a list of integers.""" 758 759 # The allowed types. 760 allowed = [ 761 'int_list', 762 ] 763 none_elem = [ 764 'int_none_list', 765 ] 766 empty = [ 767 'empty_list', 768 ] 769 770 # Checks. 771 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxListIntError, dim=(None,), basic_types=['int'], container_types=['list'])
772 773
775 """Test lib.arg_check.validate_arg() for a list of lists of integers.""" 776 777 # The allowed types. 778 allowed = [ 779 'int_list_rank2', 780 ] 781 none_elem = [ 782 'int_none_list_rank2', 783 ] 784 empty = [ 785 'empty_list_rank2', 786 ] 787 788 # Checks. 789 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxInvalidError, dim=(None,None), basic_types=['int'], container_types=['list'])
790 791
793 """Test lib.arg_check.validate_arg() for a integer or a list of integers.""" 794 795 # The allowed types. 796 allowed = [ 797 'int', 798 'int_list', 799 ] 800 none_elem = [ 801 'int_none_list', 802 ] 803 empty = [ 804 'empty_list', 805 ] 806 807 # Checks. 808 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxIntListIntError, dim=[(), (None,)], basic_types=['int'], container_types=['list'])
809 810
811 - def test_validate_arg_list(self):
812 """Test lib.arg_check.validate_arg() for a list of anything.""" 813 814 # The allowed types. 815 allowed = [ 816 'bool_list', 817 'float_list', 818 'int_list', 819 'str_list', 820 'str_num_list', 821 ] 822 none_elem = [ 823 'bool_none_list', 824 'float_none_list', 825 'int_none_list', 826 'str_none_list', 827 'str_none_num_list', 828 ] 829 empty = [ 830 'empty_list', 831 ] 832 833 # Checks. 834 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxListError, dim=(None,), basic_types=['bool', 'float', 'int', 'str'], container_types=['list'])
835 836
838 """Test lib.arg_check.validate_arg() for a list of anything or numpy array.""" 839 840 # The allowed types. 841 allowed = [ 842 'bool_list', 843 'float_list', 844 'float_numpy_array', 845 'int_list', 846 'int_numpy_array', 847 'str_list', 848 'str_num_list', 849 ] 850 none_elem = [ 851 'bool_none_list', 852 'float_none_list', 853 'int_none_list', 854 'str_none_list', 855 'str_none_num_list', 856 ] 857 empty = [ 858 'empty_list', 859 'float_numpy_array_empty', 860 'int_numpy_array_empty', 861 ] 862 863 # Checks. 864 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxArrayError, dim=(None,), basic_types=['bool', 'float', 'int', 'str'], container_types=['list', 'numpy array'])
865 866
867 - def test_validate_arg_number(self):
868 """Test lib.arg_check.validate_arg() for a number.""" 869 870 # The allowed types. 871 allowed = [ 872 'float', 873 'int', 874 ] 875 876 # Checks. 877 self.check_validate_arg(allowed=allowed, error=RelaxNumError, dim=(), basic_types=['number'])
878 879
881 """Test lib.arg_check.validate_arg() for a rank-1 list or numpy array of numbers.""" 882 883 # The allowed types. 884 allowed = [ 885 'float_list', 886 'float_numpy_array', 887 'int_list', 888 'int_numpy_array', 889 ] 890 none_elem = [ 891 'float_none_list', 892 'int_none_list', 893 ] 894 empty = [ 895 'empty_list', 896 'float_numpy_array_empty', 897 'int_numpy_array_empty', 898 ] 899 900 # Checks. 901 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxArrayNumError, dim=(None,), basic_types=['number'], container_types=['number array'])
902 903
905 """Test lib.arg_check.validate_arg() for a rank-2 list or numpy array of numbers.""" 906 907 # The allowed types. 908 allowed = [ 909 'float_list_rank2', 910 'float_numpy_matrix', 911 'int_list_rank2', 912 'int_numpy_matrix', 913 ] 914 none_elem = [ 915 'float_none_list_rank2', 916 'int_none_list_rank2', 917 ] 918 empty = [ 919 'empty_list_rank2', 920 'float_numpy_matrix_empty', 921 'int_numpy_matrix_empty', 922 ] 923 924 # Checks. 925 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxArrayNumError, dim=(None,None), basic_types=['number'], container_types=['number array'])
926 927
929 """Test lib.arg_check.validate_arg() for a rank-3 list or numpy array of numbers.""" 930 931 # The allowed types. 932 allowed = [ 933 'float_list_rank3', 934 'float_numpy_object', 935 'int_list_rank3', 936 'int_numpy_object', 937 ] 938 none_elem = [ 939 'float_none_list_rank3', 940 'int_none_list_rank3', 941 ] 942 empty = [ 943 'empty_list_rank3', 944 'float_numpy_object_empty', 945 'int_numpy_object_empty', 946 ] 947 948 # Checks. 949 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxArrayNumError, dim=(None,None,None), basic_types=['number'], container_types=['number array'])
950 951
953 """Test lib.arg_check.validate_arg() for a rank-1 list of numbers.""" 954 955 # The allowed types. 956 allowed = [ 957 'float_list', 958 'int_list', 959 ] 960 none_elem = [ 961 'float_none_list', 962 'int_none_list', 963 ] 964 empty = [ 965 'empty_list', 966 ] 967 968 # Checks. 969 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxListNumError, dim=(None,), basic_types=['number'], container_types=['list'])
970 971
973 """Test lib.arg_check.validate_arg() for a rank-2 list of numbers.""" 974 975 # The allowed types. 976 allowed = [ 977 'float_list_rank2', 978 'int_list_rank2', 979 ] 980 none_elem = [ 981 'float_none_list_rank2', 982 'int_none_list_rank2', 983 ] 984 empty = [ 985 'empty_list_rank2', 986 ] 987 988 # Checks. 989 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxListNumError, dim=(None,None), basic_types=['number'], container_types=['list'])
990 991
993 """Test lib.arg_check.validate_arg() for a rank-3 list of numbers.""" 994 995 # The allowed types. 996 allowed = [ 997 'float_list_rank3', 998 'int_list_rank3', 999 ] 1000 none_elem = [ 1001 'float_none_list_rank3', 1002 'int_none_list_rank3', 1003 ] 1004 empty = [ 1005 'empty_list_rank3', 1006 ] 1007 1008 # Checks. 1009 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxListNumError, dim=(None,None,None), basic_types=['number'], container_types=['list'])
1010 1011
1013 """Test lib.arg_check.validate_arg() for a rank-1 numpy array of numbers.""" 1014 1015 # The allowed types. 1016 allowed = [ 1017 'float_numpy_array', 1018 'int_numpy_array', 1019 ] 1020 none_elem = [ 1021 ] 1022 empty = [ 1023 'float_numpy_array_empty', 1024 'int_numpy_array_empty', 1025 ] 1026 1027 # Checks. 1028 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxNumpyNumError, dim=(None,), basic_types=['number'], container_types=['numpy array'])
1029 1030
1032 """Test lib.arg_check.validate_arg() for a rank-2 numpy array of numbers.""" 1033 1034 # The allowed types. 1035 allowed = [ 1036 'float_numpy_matrix', 1037 'int_numpy_matrix', 1038 ] 1039 none_elem = [ 1040 ] 1041 empty = [ 1042 'float_numpy_matrix_empty', 1043 'int_numpy_matrix_empty', 1044 ] 1045 1046 # Checks. 1047 self.check_validate_arg(allowed=allowed, none_elem=none_elem, error=RelaxNumpyNumError, dim=(2,2), basic_types=['number'], container_types=['numpy array']) 1048 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxNumpyNumError, dim=(None,None), basic_types=['number'], container_types=['numpy array'])
1049 1050
1052 """Test lib.arg_check.validate_arg() for a rank-3 numpy array of numbers.""" 1053 1054 # The allowed types. 1055 allowed = [ 1056 'float_numpy_object', 1057 'int_numpy_object', 1058 ] 1059 none_elem = [ 1060 ] 1061 empty = [ 1062 'float_numpy_object_empty', 1063 'int_numpy_object_empty', 1064 ] 1065 1066 # Checks. 1067 self.check_validate_arg(allowed=allowed, none_elem=none_elem, error=RelaxNumpyNumError, dim=(2,2,2), basic_types=['number'], container_types=['numpy array']) 1068 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxNumpyNumError, dim=(None,None,None), basic_types=['number'], container_types=['numpy array'])
1069 1070
1072 """Test lib.arg_check.validate_arg() for a rank-1 tuple of numbers.""" 1073 1074 # The allowed types. 1075 allowed = [ 1076 'float', 1077 'float_tuple', 1078 'int', 1079 'int_tuple', 1080 ] 1081 none_elem = [ 1082 'float_none_tuple', 1083 'int_none_tuple', 1084 ] 1085 empty = [ 1086 'empty_tuple', 1087 ] 1088 1089 # Checks. 1090 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxNumTupleNumError, dim=[(), (None,)], basic_types=['number'], container_types=['tuple'])
1091 1092
1094 """Test lib.arg_check.validate_arg() for a rank-1 tuple of numbers.""" 1095 1096 # The allowed types. 1097 allowed = [ 1098 'float_tuple', 1099 'int_tuple', 1100 ] 1101 none_elem = [ 1102 'float_none_tuple', 1103 'int_none_tuple', 1104 ] 1105 empty = [ 1106 'empty_tuple', 1107 ] 1108 1109 # Checks. 1110 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxTupleNumError, dim=(None,), basic_types=['number'], container_types=['tuple'])
1111 1112
1114 """Test lib.arg_check.validate_arg() for a rank-2 tuple of numbers.""" 1115 1116 # The allowed types. 1117 allowed = [ 1118 'float_tuple_rank2', 1119 'int_tuple_rank2', 1120 ] 1121 none_elem = [ 1122 'float_none_tuple_rank2', 1123 'int_none_tuple_rank2', 1124 ] 1125 empty = [ 1126 'empty_tuple_rank2', 1127 ] 1128 1129 # Checks. 1130 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxTupleNumError, dim=(None,None), basic_types=['number'], container_types=['tuple'])
1131 1132
1134 """Test lib.arg_check.validate_arg() for a rank-3 tuple of numbers.""" 1135 1136 # The allowed types. 1137 allowed = [ 1138 'float_tuple_rank3', 1139 'int_tuple_rank3', 1140 ] 1141 none_elem = [ 1142 'float_none_tuple_rank3', 1143 'int_none_tuple_rank3', 1144 ] 1145 empty = [ 1146 'empty_tuple_rank3', 1147 ] 1148 1149 # Checks. 1150 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxTupleNumError, dim=(None,None,None), basic_types=['number'], container_types=['tuple'])
1151 1152
1154 """Test lib.arg_check.validate_arg() for a numpy float array.""" 1155 1156 # The allowed types. 1157 allowed = [ 1158 'float_numpy_array', 1159 ] 1160 empty = [ 1161 'float_numpy_array_empty', 1162 ] 1163 1164 # Checks. 1165 self.check_validate_arg(allowed=allowed, empty=empty, error=RelaxNumpyFloatError, dim=(None,), basic_types=['float'], container_types=['numpy array'])
1166 1167
1169 """Test lib.arg_check.validate_arg() for a numpy matrix of floats.""" 1170 1171 # The allowed types. 1172 allowed = [ 1173 'float_numpy_matrix', 1174 ] 1175 empty = [ 1176 'float_numpy_matrix_empty', 1177 ] 1178 1179 # Checks. 1180 self.check_validate_arg(allowed=allowed, empty=empty, error=RelaxNumpyFloatError, dim=(None,None), basic_types=['float'], container_types=['numpy array'])
1181 1182
1184 """Test lib.arg_check.validate_arg() for a numpy rank-3 object of floats.""" 1185 1186 # The allowed types. 1187 allowed = [ 1188 'float_numpy_object', 1189 ] 1190 empty = [ 1191 'float_numpy_object_empty', 1192 ] 1193 1194 # Checks. 1195 self.check_validate_arg(allowed=allowed, error=RelaxNumpyFloatError, dim=(2,2,2), basic_types=['float'], container_types=['numpy array']) 1196 self.check_validate_arg(allowed=allowed, empty=empty, error=RelaxNumpyFloatError, dim=(None,None,None), basic_types=['float'], container_types=['numpy array'])
1197 1198
1200 """Test lib.arg_check.validate_arg() for a numpy int array.""" 1201 1202 # The allowed types. 1203 allowed = [ 1204 'int_numpy_array', 1205 ] 1206 empty = [ 1207 'int_numpy_array_empty', 1208 ] 1209 1210 # Checks. 1211 self.check_validate_arg(allowed=allowed, error=RelaxNumpyIntError, dim=(2,), basic_types=['int'], container_types=['numpy array']) 1212 self.check_validate_arg(allowed=allowed, empty=empty, error=RelaxNumpyIntError, dim=(None,), basic_types=['int'], container_types=['numpy array'])
1213 1214
1216 """Test lib.arg_check.validate_arg() for a numpy matrix of ints.""" 1217 1218 # The allowed types. 1219 allowed = [ 1220 'int_numpy_matrix', 1221 ] 1222 empty = [ 1223 'int_numpy_matrix_empty', 1224 ] 1225 1226 # Checks. 1227 self.check_validate_arg(allowed=allowed, empty=empty, error=RelaxNumpyIntError, dim=(None,None), basic_types=['int'], container_types=['numpy array'])
1228 1229
1231 """Test lib.arg_check.validate_arg() for a numpy rank-3 object of ints.""" 1232 1233 # The allowed types. 1234 allowed = [ 1235 'int_numpy_object', 1236 ] 1237 empty = [ 1238 'int_numpy_object_empty', 1239 ] 1240 1241 # Checks. 1242 self.check_validate_arg(allowed=allowed, error=RelaxNumpyIntError, dim=(2,2,2), basic_types=['int'], container_types=['numpy array']) 1243 self.check_validate_arg(allowed=allowed, empty=empty, error=RelaxNumpyIntError, dim=(None,None,None), basic_types=['int'], container_types=['numpy array'])
1244 1245
1246 - def test_validate_arg_str(self):
1247 """Test lib.arg_check.validate_arg() for a basic string type.""" 1248 1249 # The allowed types. 1250 allowed = [ 1251 'str', 1252 ] 1253 1254 # Checks. 1255 self.check_validate_arg(allowed=allowed, error=RelaxStrError, dim=(), basic_types=['str'])
1256 1257
1258 - def test_validate_arg_str_list(self):
1259 """Test lib.arg_check.validate_arg() for a list of strings.""" 1260 1261 # The allowed types. 1262 allowed = [ 1263 'str_list', 1264 ] 1265 none_elem = [ 1266 'str_none_list', 1267 ] 1268 empty = [ 1269 'empty_list', 1270 ] 1271 1272 # Checks. 1273 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxListStrError, dim=(None,), basic_types=['str'], container_types=['list'])
1274 1275
1277 """Test lib.arg_check.validate_arg() for a list of lists of strings.""" 1278 1279 # The allowed types. 1280 allowed = [ 1281 'str_list_rank2', 1282 ] 1283 none_elem = [ 1284 'str_none_list_rank2', 1285 ] 1286 empty = [ 1287 'empty_list_rank2', 1288 ] 1289 1290 # Checks. 1291 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxInvalidError, dim=(None,None), basic_types=['str'], container_types=['list'])
1292 1293
1295 """Test lib.arg_check.validate_arg() for a string or a readable file object.""" 1296 1297 # The allowed types. 1298 allowed = [ 1299 'str', 1300 'file_object_read', 1301 'file_object_rw', 1302 ] 1303 1304 # Checks. 1305 self.check_validate_arg(allowed=allowed, error=RelaxStrFileError, basic_types=['str', 'file object read'])
1306 1307
1309 """Test lib.arg_check.validate_arg() for a string or a writable file object.""" 1310 1311 # The allowed types. 1312 allowed = [ 1313 'str', 1314 'file_object_rw', 1315 'file_object_write', 1316 'inst_file' 1317 ] 1318 1319 # Checks. 1320 self.check_validate_arg(allowed=allowed, error=RelaxStrFileError, basic_types=['str', 'file object write'])
1321 1322
1324 """Test lib.arg_check.validate_arg() for a string or a readable file object, or a list of strings or a readable file objects.""" 1325 1326 # The allowed types. 1327 allowed = [ 1328 'file_object_list_read', 1329 'file_object_list_rw', 1330 'file_object_read', 1331 'file_object_rw', 1332 'str', 1333 'str_list', 1334 ] 1335 none_elem = [ 1336 'str_none_list', 1337 ] 1338 empty = [ 1339 'empty_list', 1340 ] 1341 1342 # Checks. 1343 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxStrFileListStrFileError, dim=[(), (None,)], basic_types=['str', 'file object read'], container_types=['list'])
1344 1345
1347 """Test lib.arg_check.validate_arg() for a string or a writable file object, or a list of strings or a writable file objects.""" 1348 1349 # The allowed types. 1350 allowed = [ 1351 'file_object_list_rw', 1352 'file_object_list_write', 1353 'file_object_rw', 1354 'file_object_write', 1355 'inst_file', 1356 'str', 1357 'str_list', 1358 ] 1359 none_elem = [ 1360 'str_none_list', 1361 ] 1362 empty = [ 1363 'empty_list', 1364 ] 1365 1366 # Checks. 1367 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxStrFileListStrFileError, dim=[(), (None,)], basic_types=['str', 'file object write'], container_types=['list'])
1368 1369
1371 """Test lib.arg_check.validate_arg() for a string or list of strings.""" 1372 1373 # The allowed types. 1374 allowed = [ 1375 'str', 1376 'str_list', 1377 ] 1378 none_elem = [ 1379 'str_none_list', 1380 ] 1381 empty = [ 1382 'empty_list', 1383 ] 1384 1385 # Checks. 1386 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxStrListStrError, dim=[(), (None,)], basic_types=['str'], container_types=['list'])
1387 1388
1389 - def test_validate_arg_tuple(self):
1390 """Test lib.arg_check.validate_arg() for a tuple of anything.""" 1391 1392 # The allowed types. 1393 allowed = [ 1394 'bool_tuple', 1395 'float_tuple', 1396 'int_tuple', 1397 'str_tuple', 1398 ] 1399 none_elem = [ 1400 'bool_none_tuple', 1401 'float_none_tuple', 1402 'int_none_tuple', 1403 'str_none_tuple', 1404 ] 1405 empty = [ 1406 'empty_tuple', 1407 ] 1408 1409 # Checks. 1410 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxTupleError, dim=(None,), container_types=['tuple']) 1411 self.check_validate_arg(allowed=allowed, none_elem=none_elem, empty=empty, error=RelaxTupleError, dim=(None,), basic_types=['bool', 'number', 'str'], container_types=['tuple'])
1412