11import json
2- import os
32import pathlib
43import sys
54
65from typing import Callable , Dict , List , Tuple , Union
76
7+
88import pytest
99
1010
2323
2424@pytest .fixture
2525def sample_report_path () -> pathlib .Path :
26- return test_folder / 'sample_report.json'
26+ return test_folder / 'sample_report.json'
2727
2828
2929@pytest .fixture
@@ -41,7 +41,7 @@ def test_collect_longrepr__returns_non_empty(json_dict):
4141
4242@pytest .fixture
4343def div_zero_report_path () -> pathlib .Path :
44- return test_folder / 'json_dict_div_zero_try_except.json'
44+ return test_folder / 'json_dict_div_zero_try_except.json'
4545
4646
4747@pytest .fixture
@@ -74,7 +74,7 @@ def test_collect_longrepr_from_multiple_reports__returns_non_empty(
7474 assert result
7575
7676
77- @pytest .fixture (params = ( 'Korean' , 'English' , 'Bahasa Indonesia' , 'Chinese' , 'French' , 'German' , 'Italian' , 'Japanese' , 'Nederlands' , 'Spanish' , 'Thai' , 'Vietnamese' ))
77+ @pytest .fixture (params = tuple ( path . stem for path in pathlib . Path ( 'locale' ). glob ( '*.json' ) ))
7878def explanation_in (request ) -> str :
7979 return request .param
8080
@@ -92,6 +92,7 @@ def homework(explanation_in:str) -> Tuple[str]:
9292 'Japanese' : ('宿題' ,),
9393 'Nederlands' : ('Huiswerk' ,),
9494 'Spanish' : ('Tarea' ,),
95+ 'Swedish' : ('Läxa' ,),
9596 'Thai' : ('การบ้าน' ,),
9697 'Vietnamese' : ('Bài tập' ,),
9798 }
@@ -116,12 +117,38 @@ def msg(explanation_in:str) -> str:
116117 'Japanese' : 'メッセ' ,
117118 'Nederlands' : 'Foutmelding' , # error message
118119 'Spanish' : 'Mensaje' ,
120+ 'Swedish' : 'Meddelande' ,
119121 'Thai' : 'ข้อความ' ,
120122 'Vietnamese' : 'thông báo' , # notification
121123 }
122124 return d [explanation_in ].lower ()
123125
124126
127+ @pytest .fixture
128+ def instruction (explanation_in :str ) -> str :
129+ d = {
130+ 'Korean' : ('지침' ,),
131+ 'English' : ('Instruction' ,),
132+ 'Bahasa Indonesia' : ('Petunjuk' , 'Instruksi' ),
133+ 'Chinese' : ('说明' ,),
134+ 'French' : ('instruction' ,),
135+ 'German' : ('Aufgabenanweisung' ,),
136+ 'Italian' : ('istruzione' ,),
137+ 'Japanese' : ('指示' ,),
138+ 'Nederlands' : ('instructie' ,),
139+ 'Spanish' : ('instrucción' ,),
140+ 'Swedish' : ('instruktion' ,),
141+ 'Thai' : ('แนะนำ' ,),
142+ 'Vietnamese' : ('hướng dẫn' ,),
143+ }
144+ return tuple (
145+ map (
146+ lambda x : x .lower (),
147+ d [explanation_in ]
148+ )
149+ )
150+
151+
125152def test_get_directive (explanation_in :str , homework :Tuple [str ]):
126153 result = ai_tutor .get_directive (explanation_in = explanation_in )
127154
@@ -158,36 +185,12 @@ def test_get_report__header__footer(explanation_in:str, msg:str, func:Callable):
158185
159186@pytest .fixture
160187def sample_student_code_path () -> pathlib .Path :
161- return test_folder / 'sample_code.py'
188+ return test_folder / 'sample_code.py'
162189
163190
164191@pytest .fixture
165192def sample_readme_path () -> pathlib .Path :
166- return test_folder / 'sample_readme.md'
167-
168-
169- @pytest .fixture
170- def instruction (explanation_in :str ) -> str :
171- d = {
172- 'Korean' : ('지침' ,),
173- 'English' : ('Instruction' ,),
174- 'Bahasa Indonesia' : ('Petunjuk' , 'Instruksi' ),
175- 'Chinese' : ('说明' ,),
176- 'French' : ('instruction' ,),
177- 'German' : ('Aufgabenanweisung' ,),
178- 'Italian' : ('istruzione' ,),
179- 'Japanese' : ('指示' ,),
180- 'Nederlands' : ('instructie' ,),
181- 'Spanish' : ('instrucción' ,),
182- 'Thai' : ('แนะนำ' ,),
183- 'Vietnamese' : ('hướng dẫn' ,),
184- }
185- return tuple (
186- map (
187- lambda x : x .lower (),
188- d [explanation_in ]
189- )
190- )
193+ return test_folder / 'sample_readme.md'
191194
192195
193196def test_get_instruction_block (
0 commit comments