Skip to content

Commit 5c0c3ee

Browse files
committed
minor changes
1 parent 16e909d commit 5c0c3ee

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

test/backends/test_watsonx.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,42 @@
1515
@pytest.fixture(scope="module")
1616
def backend():
1717
"""Shared Watson backend for all tests in this module."""
18-
return WatsonxAIBackend(
18+
if os.environ.get("CICD") == 1:
19+
pytest.skip("Skipping watsonx tests.")
20+
else:
21+
return WatsonxAIBackend(
1922
model_id="ibm/granite-3-3-8b-instruct",
2023
formatter=TemplateFormatter(model_id="ibm-granite/granite-3.3-8b-instruct"),
2124
)
2225

2326

2427
@pytest.fixture(scope="function")
25-
def session(backend):
26-
"""Fresh Watson session for each test."""
27-
session = MelleaSession(backend, ctx=LinearContext(is_chat_context=True))
28-
yield session
29-
session.reset()
28+
def session(backend: WatsonxAIBackend):
29+
if os.environ.get("CICD") == 1:
30+
pytest.skip("Skipping watsonx tests.")
31+
else:
32+
"""Fresh Watson session for each test."""
33+
session = MelleaSession(backend, ctx=LinearContext(is_chat_context=True))
34+
yield session
35+
session.reset()
3036

3137

3238
@pytest.mark.qualitative
33-
def test_instruct(session):
39+
def test_instruct(session: MelleaSession):
3440
result = session.instruct("Compute 1+1.")
3541
assert isinstance(result, ModelOutputThunk)
3642
assert "2" in result.value # type: ignore
3743

3844

3945
@pytest.mark.qualitative
40-
def test_multiturn(session):
46+
def test_multiturn(session: MelleaSession):
4147
session.instruct("What is the capital of France?")
4248
answer = session.instruct("Tell me the answer to the previous question.")
4349
assert "Paris" in answer.value # type: ignore
4450

4551

4652
@pytest.mark.qualitative
47-
def test_format(session):
53+
def test_format(session: MelleaSession):
4854
class Person(pydantic.BaseModel):
4955
name: str
5056
# it does not support regex patterns in json schema
@@ -78,7 +84,7 @@ class Email(pydantic.BaseModel):
7884

7985

8086
@pytest.mark.qualitative
81-
def test_generate_from_raw(session):
87+
def test_generate_from_raw(session: MelleaSession):
8288
prompts = ["what is 1+1?", "what is 2+2?", "what is 3+3?", "what is 4+4?"]
8389

8490
results = session.backend._generate_from_raw(

test/stdlib_basics/test_session.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os
2+
13
import pytest
24

35
from mellea.stdlib.base import ModelOutputThunk

0 commit comments

Comments
 (0)