From 063cf544952124b90551914273af36ab11671faa Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 9 Jul 2024 12:16:50 -0300 Subject: [PATCH] fix: update test_create_function to use pathlib.Path (#2605) feat(test_validate_code.py): update test_create_function to use pathlib.Path instead of math.sin to check if it breaks ci --- tests/unit/test_validate_code.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/unit/test_validate_code.py b/tests/unit/test_validate_code.py index cacf3669c..c003ab10d 100644 --- a/tests/unit/test_validate_code.py +++ b/tests/unit/test_validate_code.py @@ -1,14 +1,11 @@ +from pathlib import Path from unittest import mock import pytest -from langflow.utils.validate import ( - create_function, - execute_function, - extract_function_name, - validate_code, -) from requests.exceptions import MissingSchema +from langflow.utils.validate import create_function, execute_function, extract_function_name, validate_code + def test_validate_code(): # Test case with a valid import and function @@ -95,13 +92,13 @@ def my_function(x): def test_create_function(): code = """ -import math +from pathlib import Path -def my_function(x): - return math.sin(x) + 1 +def my_function(x: str) -> Path: + return Path(x) """ function_name = extract_function_name(code) function = create_function(code, function_name) - result = function(0.5) - assert result == 1.479425538604203 + result = function("test") + assert result == Path("test")