Coverage for tests/test_translate.py: 92%

13 statements  

« prev     ^ index     » next       coverage.py v7.6.3, created at 2024-10-15 14:54 -0500

1import pytest 

2import mall 

3import polars as pl 

4import pyarrow 

5 

6import shutil 

7import os 

8 

9if os._exists("_test_cache"): 

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

11 

12 

13def 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 )