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
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-07-09 12:16:50 -03:00 • committed by GitHub
commit 063cf54495
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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")