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:
parent
c20630b77d
commit
063cf54495
1 changed files with 8 additions and 11 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue