Example #1
0
    def test_not_string_lists(self):
        with self.assertRaises(TypeError):
            _ = dtype_utils.validate_string_args([14], ['meh'])

        with self.assertRaises(TypeError):
            _ = dtype_utils.validate_string_args(14, ['meh'])

        with self.assertRaises(TypeError):
            _ = dtype_utils.validate_string_args({'dfdf': 14}, ['meh'])
Example #2
0
 def test_names_not_list_of_strings(self):
     with self.assertRaises(TypeError):
         _ = dtype_utils.validate_string_args(['a', 'v'], {'a': 1, 'v': 43})
Example #3
0
 def test_unequal_lengths(self):
     expected = ['a', 'b']
     actual = dtype_utils.validate_string_args(expected + ['c'], ['a', 'b'])
     for exp, ret in zip(expected, actual):
         self.assertEqual(exp, ret)
Example #4
0
 def test_name_not_string(self):
     actual = ['ghghg']
     ret = dtype_utils.validate_string_args(actual, [np.arange(3)])
     self.assertEqual(ret, actual)
Example #5
0
 def test_multi(self):
     expected = ['abc', 'def']
     returned = dtype_utils.validate_string_args(['   ' + expected[0], expected[1] + '    '], ['meh', 'foo'])
     for exp, ret in zip(expected, returned):
         self.assertEqual(exp, ret)
Example #6
0
 def test_single(self):
     expected = 'fd'
     [ret] = dtype_utils.validate_string_args(expected , 'meh')
     self.assertEqual(expected, ret)
Example #7
0
 def test_spaces(self):
     expected = 'fd'
     [ret] = dtype_utils.validate_string_args(['  ' + expected + '    '], ['meh'])
     self.assertEqual(expected, ret)
Example #8
0
 def test_empty(self):
     with self.assertRaises(ValueError):
         _ = dtype_utils.validate_string_args(['      '], ['meh'])