Skip to content

Commit b975ec1

Browse files
committed
handle python versions in tests
1 parent 8e64cf7 commit b975ec1

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

tests/test_open_ai_mixin.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import sys
2-
3-
import pytest
4-
52
from databricks.sdk.core import Config
63

74

@@ -17,14 +14,19 @@ def test_open_ai_client(monkeypatch):
1714
assert client.api_key == "test_token"
1815

1916

20-
@pytest.mark.skipif(sys.version_info <= (3, 7), reason="Requires Python > 3.7")
2117
def test_langchain_open_ai_client(monkeypatch):
2218
from databricks.sdk import WorkspaceClient
23-
24-
monkeypatch.setenv('DATABRICKS_HOST', 'test_host')
25-
monkeypatch.setenv('DATABRICKS_TOKEN', 'test_token')
26-
w = WorkspaceClient(config=Config())
27-
client = w.serving_endpoints.get_langchain_chat_open_ai_client("databricks-meta-llama-3-1-70b-instruct")
28-
29-
assert client.openai_api_base == "https://test_host/serving-endpoints"
30-
assert client.model_name == "databricks-meta-llama-3-1-70b-instruct"
19+
print(sys.version_info)
20+
print(sys.version_info <= (3,7))
21+
if sys.version_info <= (3, 7):
22+
with pytest.raises(ImportError):
23+
w = WorkspaceClient(config=Config())
24+
client = w.serving_endpoints.get_langchain_chat_open_ai_client("databricks-meta-llama-3-1-70b-instruct")
25+
else:
26+
monkeypatch.setenv('DATABRICKS_HOST', 'test_host')
27+
monkeypatch.setenv('DATABRICKS_TOKEN', 'test_token')
28+
w = WorkspaceClient(config=Config())
29+
client = w.serving_endpoints.get_langchain_chat_open_ai_client("databricks-meta-llama-3-1-70b-instruct")
30+
31+
assert client.openai_api_base == "https://test_host/serving-endpoints"
32+
assert client.model_name == "databricks-meta-llama-3-1-70b-instruct"

0 commit comments

Comments
 (0)