예제 #1
0
 def test_elementtype(self):
     example_list = [1.0, 2.0, 3.0]
     self.assertEqual(
         validate_list("example_list", example_list, elementtype="float"),
         True)
     example_list = [1.0, "a", 3.0]
     self.assertRaises(ValueError,
                       validate_list,
                       "example_list",
                       example_list,
                       elementtype="float")
     example_list = [1.0, 2.2, 3.0]
     self.assertRaises(ValueError,
                       validate_list,
                       "example_list",
                       example_list,
                       elementtype="int")
     example_list = [1, 2, 3]
     self.assertEqual(
         validate_list("example_list", example_list, elementtype="int"),
         True)
     example_list = ['a', 'b', 'c']
     self.assertEqual(
         validate_list("example_list", example_list, elementtype="string"),
         True)
     example_list = ['a', 2.2, 'c']
     self.assertRaises(ValueError,
                       validate_list,
                       "example_list",
                       example_list,
                       elementtype="string")
예제 #2
0
 def test_descending(self):
     example_list = [3.0, 2.0, 1.0]
     self.assertEqual(
         validate_list("example_list", example_list, order="descending"),
         True)
     example_list = [2.0, 3.0, 1.0]
     self.assertRaises(ValueError,
                       validate_list,
                       "example_list",
                       example_list,
                       order="descending")
     example_list = [3.0, 2.0, np.NaN]
     self.assertRaises(ValueError,
                       validate_list,
                       "example_list",
                       example_list,
                       order="descending")
     example_list = [
         3.0,
         np.NaN,
         2.0,
         1.0,
     ]
     self.assertRaises(ValueError,
                       validate_list,
                       "example_list",
                       example_list,
                       order="descending")
예제 #3
0
 def test_empty(self):
     example_list = []
     self.assertEqual(validate_list("example_list", example_list), True)
     self.assertRaises(ValueError,
                       validate_list,
                       "example_list",
                       example_list,
                       empty_allowed=False)
예제 #4
0
 def test_unique(self):
     example_list = [3.0, 2.0, 1.0]
     self.assertEqual(
         validate_list("example_list", example_list, unique=True), True)
     example_list = [3.0, 3.0, 1.0]
     self.assertRaises(ValueError,
                       validate_list,
                       "example_list",
                       example_list,
                       unique=True)
예제 #5
0
 def test_list(self):
     example_list = [1.0, 2.0, 3.0]
     self.assertEqual(validate_list("example_list", example_list), True)
     example_tuple = (1.0, 2.0, 3.0)
     self.assertEqual(validate_list("example_tuple", example_tuple), True)