Exemplo n.º 1
0
 def test_function_not_found(self):
     with self.assertRaises(ValueError) as cm:
         load_custom_func("tests.test_custom:my_custom_fun")
     self.assertEqual(
         'function "tests.test_custom:my_custom_fun" not found,'
         ' unknown attribute "my_custom_fun"', f"{cm.exception}")
Exemplo n.º 2
0
 def test_not_a_function(self):
     with self.assertRaises(ValueError) as cm:
         load_custom_func("tests.test_custom:my_custom_var")
     self.assertEqual('"tests.test_custom:my_custom_var" is not callable',
                      f"{cm.exception}")
Exemplo n.º 3
0
 def test_module_not_found(self):
     with self.assertRaises(ValueError) as cm:
         load_custom_func("test.test_custom:my_custom_func")
     self.assertEqual(
         'module for function "test.test_custom:my_custom_func" not found',
         f"{cm.exception}")
Exemplo n.º 4
0
 def test_invalid_id(self):
     with self.assertRaises(ValueError) as cm:
         load_custom_func("tests.test_custom:my-custom-func")
     self.assertEqual(
         'func_ref "tests.test_custom:my-custom-func" is invalid,'
         ' "my-custom-func" is not a valid identifier', f"{cm.exception}")
Exemplo n.º 5
0
 def test_invalid_ref(self):
     with self.assertRaises(ValueError) as cm:
         load_custom_func("tests.test_custom.my_custom_func")
     self.assertEqual(
         'func_ref "tests.test_custom.my_custom_func" is invalid,'
         ' format must be <module>:<function>', f"{cm.exception}")
Exemplo n.º 6
0
 def test_ok_class_method(self):
     func = load_custom_func(
         "tests.test_custom:LoadCustomFunctionTest.my_custom_func")
     self.assertIsInstance(func(xr.Dataset()), xr.Dataset)
Exemplo n.º 7
0
 def test_ok(self):
     func = load_custom_func("tests.test_custom:my_custom_func")
     self.assertIsInstance(func(xr.Dataset()), xr.Dataset)