|
15 | 15 | @pytest.fixture(scope="module") |
16 | 16 | def backend(): |
17 | 17 | """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( |
19 | 22 | model_id="ibm/granite-3-3-8b-instruct", |
20 | 23 | formatter=TemplateFormatter(model_id="ibm-granite/granite-3.3-8b-instruct"), |
21 | 24 | ) |
22 | 25 |
|
23 | 26 |
|
24 | 27 | @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() |
30 | 36 |
|
31 | 37 |
|
32 | 38 | @pytest.mark.qualitative |
33 | | -def test_instruct(session): |
| 39 | +def test_instruct(session: MelleaSession): |
34 | 40 | result = session.instruct("Compute 1+1.") |
35 | 41 | assert isinstance(result, ModelOutputThunk) |
36 | 42 | assert "2" in result.value # type: ignore |
37 | 43 |
|
38 | 44 |
|
39 | 45 | @pytest.mark.qualitative |
40 | | -def test_multiturn(session): |
| 46 | +def test_multiturn(session: MelleaSession): |
41 | 47 | session.instruct("What is the capital of France?") |
42 | 48 | answer = session.instruct("Tell me the answer to the previous question.") |
43 | 49 | assert "Paris" in answer.value # type: ignore |
44 | 50 |
|
45 | 51 |
|
46 | 52 | @pytest.mark.qualitative |
47 | | -def test_format(session): |
| 53 | +def test_format(session: MelleaSession): |
48 | 54 | class Person(pydantic.BaseModel): |
49 | 55 | name: str |
50 | 56 | # it does not support regex patterns in json schema |
@@ -78,7 +84,7 @@ class Email(pydantic.BaseModel): |
78 | 84 |
|
79 | 85 |
|
80 | 86 | @pytest.mark.qualitative |
81 | | -def test_generate_from_raw(session): |
| 87 | +def test_generate_from_raw(session: MelleaSession): |
82 | 88 | prompts = ["what is 1+1?", "what is 2+2?", "what is 3+3?", "what is 4+4?"] |
83 | 89 |
|
84 | 90 | results = session.backend._generate_from_raw( |
|
0 commit comments