Coverage for tests/test_translate.py: 92%

1 import pytest

2 import mall

3 import polars as pl

4 import pyarrow

5

6 import shutil

7 import os

8

9 if os._exists("_test_cache"):

10 shutil.rmtree("_test_cache", ignore_errors=True)

11

12

13 def test_translate_prompt():

14 df = pl.DataFrame(dict(x="x"))

15 df.llm.use("test", "content", _cache="_test_cache")

16 x = df.llm.translate("x", language="spanish")

17 assert (

18 x["translation"][0]

19 == "You are a helpful translation engine. You will return only the translation text, no explanations. The target language to translate to is: spanish. The answer is the translation of the following text:\n{}"

20 )