Kaynağa Gözat

attempt to fix failing tests on python 3.9

Toan Quach 6 ay önce
ebeveyn
işleme
03fe9a6c86

+ 8 - 1
taipy/core/config/checkers/_data_node_config_checker.py

@@ -227,7 +227,14 @@ class _DataNodeConfigChecker(_ConfigChecker):
                             prop_key,
                             prop_value,
                             f"`{prop_key}` of DataNodeConfig `{data_node_config_id}` must be"
-                            f" populated with a {class_type.__qualname__}.",
+                            f" populated with a {'Callable' if class_type == Callable else class_type.__name__}.",
+                        )
+                    if class_type == Callable and callable(prop_value) and prop_value.__name__ == "<lambda>":
+                        self._error(
+                            prop_key,
+                            prop_value,
+                            f"`{prop_key}` of DataNodeConfig `{data_node_config_id}` must be"
+                            f" populated with a Callable and not a lambda.",
                         )
 
     def _check_exposed_type(self, data_node_config_id: str, data_node_config: DataNodeConfig):

+ 16 - 0
tests/core/config/checkers/test_data_node_config_checker.py

@@ -581,6 +581,22 @@ class TestDataNodeConfigChecker:
         Config.check()
         assert len(Config._collector.errors) == 0
 
+        config._sections[DataNodeConfig.name]["new"].storage_type = "generic"
+        config._sections[DataNodeConfig.name]["new"].properties = {"write_fct": lambda x: x, "read_fct": lambda y: y}
+        with pytest.raises(SystemExit):
+            Config._collector = IssueCollector()
+            Config.check()
+        assert len(Config._collector.errors) == 2
+        expected_error_messages = [
+            "`write_fct` of DataNodeConfig `new` must be populated with a Callable and not a lambda."
+            " Current value of property `write_fct` is <function TestDataNodeConfigChecker."
+            "test_check_callable_properties.<locals>.<lambda>",
+            "`read_fct` of DataNodeConfig `new` must be populated with a Callable and not a lambda."
+            " Current value of property `read_fct` is <function TestDataNodeConfigChecker."
+            "test_check_callable_properties.<locals>.<lambda>",
+        ]
+        assert all(message in caplog.text for message in expected_error_messages)
+
     def test_check_read_write_fct_args(self, caplog):
         config = Config._applied_config
         Config._compile_configs()