33import pathlib
44import sys
55
6- from typing import Dict , Union , List
6+ from typing import Callable , Dict , List , Tuple , Union
77
88import pytest
99
@@ -57,24 +57,30 @@ def test_collect_longrepr(json_dict_div_zero_try_except:Dict):
5757 assert result
5858
5959
60- @pytest .fixture (params = ('Korean' , 'English' , 'Japanese' , 'Chinese' , 'Spanish' , 'French' , 'German' , 'Thai' ))
60+ @pytest .fixture (params = ('Korean' , 'English' , 'Japanese' , 'Chinese' , 'Spanish' , 'French' , 'German' , 'Italian' , ' Thai' ))
6161def explanation_in (request ) -> str :
6262 return request .param .capitalize ()
6363
6464
6565@pytest .fixture
66- def homework (explanation_in :str ) -> str :
66+ def homework (explanation_in :str ) -> Tuple [ str ] :
6767 d = {
68- 'Korean' : '숙제' ,
69- 'English' : 'Homework' ,
70- 'Japanese' : '宿題' ,
71- 'Chinese' : '作业' ,
72- 'Spanish' : 'Tarea' ,
73- 'French' : 'Devoir' ,
74- 'German' : 'Hausaufgabe' ,
75- 'Thai' : 'การบ้าน' ,
68+ 'Korean' : ('숙제' ,),
69+ 'English' : ('Homework' ,),
70+ 'Japanese' : ('宿題' ,),
71+ 'Chinese' : ('作业' ,),
72+ 'Spanish' : ('Tarea' ,),
73+ 'French' : ('Devoir' ,),
74+ 'German' : ('Hausaufgabe' ,),
75+ 'Italian' : ('Compito' , 'Compiti' ),
76+ 'Thai' : ('การบ้าน' ,),
7677 }
77- return d [explanation_in ].lower ()
78+ return tuple (
79+ map (
80+ lambda x : x .lower (),
81+ d [explanation_in ]
82+ )
83+ )
7884
7985
8086@pytest .fixture
@@ -87,19 +93,36 @@ def msg(explanation_in:str) -> str:
8793 'Spanish' : 'Mensaje' ,
8894 'French' : 'Message' ,
8995 'German' : 'Fehlermeldung' ,
96+ 'Italian' : 'Messaggio' ,
9097 'Thai' : 'ข้อความ' ,
9198 }
9299 return d [explanation_in ].lower ()
93100
94101
95- def test_get_instruction (explanation_in , homework ,):
102+ def test_get_directive (explanation_in :str , homework :Tuple [str ]):
103+ result = ai_tutor .get_directive (explanation_in = explanation_in )
104+
105+ assert any (
106+ map (
107+ lambda x : x in result .lower (),
108+ homework
109+ )
110+ )
111+
112+
113+ def test_get_instruction (explanation_in :str , homework :Tuple [str ],):
96114 result = ai_tutor .get_directive (explanation_in = explanation_in )
97115
98- assert homework in result .lower ()
116+ assert any (
117+ map (
118+ lambda x : x in result .lower (),
119+ homework
120+ )
121+ )
99122
100123
101124@pytest .mark .parametrize ("func" , (ai_tutor .get_report_header , ai_tutor .get_report_footer ))
102- def test_get_report__header__footer (explanation_in , msg , func ):
125+ def test_get_report__header__footer (explanation_in : str , msg : str , func : Callable ):
103126
104127 result = func (explanation_in = explanation_in )
105128
@@ -126,6 +149,7 @@ def instruction(explanation_in:str) -> str:
126149 'Spanish' : 'instrucción' ,
127150 'French' : 'instruction' ,
128151 'German' : 'Aufgabenanweisung' ,
152+ 'Italian' : 'istruzione' ,
129153 'Thai' : 'แนะนำ' ,
130154 }
131155 return d [explanation_in ].lower ()
@@ -135,7 +159,7 @@ def test_get_code_instruction(
135159 sample_student_code_path :pathlib .Path ,
136160 sample_readme_path :pathlib .Path ,
137161 explanation_in :str ,
138- homework :str ,
162+ homework :Tuple [ str ] ,
139163 instruction :str ,
140164 ):
141165
@@ -145,7 +169,12 @@ def test_get_code_instruction(
145169 explanation_in = explanation_in
146170 ).lower ()
147171
148- assert homework in result
172+ assert any (
173+ map (
174+ lambda x : x in result ,
175+ homework
176+ )
177+ )
149178 assert instruction in result
150179
151180
@@ -155,7 +184,8 @@ def test_get_the_question(
155184 sample_student_code_path :pathlib .Path ,
156185 sample_readme_path :pathlib .Path ,
157186 explanation_in :str ,
158- homework :str , msg :str ,
187+ homework :Tuple [str ],
188+ msg :str ,
159189 instruction :str ,
160190 ):
161191 result = ai_tutor .get_the_question (
@@ -165,7 +195,12 @@ def test_get_the_question(
165195 explanation_in = explanation_in ,
166196 ).lower ()
167197
168- assert homework in result
198+ assert any (
199+ map (
200+ lambda x : x in result ,
201+ homework
202+ )
203+ )
169204 assert msg in result
170205 assert instruction in result
171206
0 commit comments