3
3
import pathlib
4
4
import sys
5
5
6
- from typing import Dict , Union , List
6
+ from typing import Callable , Dict , List , Tuple , Union
7
7
8
8
import pytest
9
9
@@ -57,24 +57,30 @@ def test_collect_longrepr(json_dict_div_zero_try_except:Dict):
57
57
assert result
58
58
59
59
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' ))
61
61
def explanation_in (request ) -> str :
62
62
return request .param .capitalize ()
63
63
64
64
65
65
@pytest .fixture
66
- def homework (explanation_in :str ) -> str :
66
+ def homework (explanation_in :str ) -> Tuple [ str ] :
67
67
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' : ('การบ้าน' ,),
76
77
}
77
- return d [explanation_in ].lower ()
78
+ return tuple (
79
+ map (
80
+ lambda x : x .lower (),
81
+ d [explanation_in ]
82
+ )
83
+ )
78
84
79
85
80
86
@pytest .fixture
@@ -87,19 +93,36 @@ def msg(explanation_in:str) -> str:
87
93
'Spanish' : 'Mensaje' ,
88
94
'French' : 'Message' ,
89
95
'German' : 'Fehlermeldung' ,
96
+ 'Italian' : 'Messaggio' ,
90
97
'Thai' : 'ข้อความ' ,
91
98
}
92
99
return d [explanation_in ].lower ()
93
100
94
101
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 ],):
96
114
result = ai_tutor .get_directive (explanation_in = explanation_in )
97
115
98
- assert homework in result .lower ()
116
+ assert any (
117
+ map (
118
+ lambda x : x in result .lower (),
119
+ homework
120
+ )
121
+ )
99
122
100
123
101
124
@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 ):
103
126
104
127
result = func (explanation_in = explanation_in )
105
128
@@ -126,6 +149,7 @@ def instruction(explanation_in:str) -> str:
126
149
'Spanish' : 'instrucción' ,
127
150
'French' : 'instruction' ,
128
151
'German' : 'Aufgabenanweisung' ,
152
+ 'Italian' : 'istruzione' ,
129
153
'Thai' : 'แนะนำ' ,
130
154
}
131
155
return d [explanation_in ].lower ()
@@ -135,7 +159,7 @@ def test_get_code_instruction(
135
159
sample_student_code_path :pathlib .Path ,
136
160
sample_readme_path :pathlib .Path ,
137
161
explanation_in :str ,
138
- homework :str ,
162
+ homework :Tuple [ str ] ,
139
163
instruction :str ,
140
164
):
141
165
@@ -145,7 +169,12 @@ def test_get_code_instruction(
145
169
explanation_in = explanation_in
146
170
).lower ()
147
171
148
- assert homework in result
172
+ assert any (
173
+ map (
174
+ lambda x : x in result ,
175
+ homework
176
+ )
177
+ )
149
178
assert instruction in result
150
179
151
180
@@ -155,7 +184,8 @@ def test_get_the_question(
155
184
sample_student_code_path :pathlib .Path ,
156
185
sample_readme_path :pathlib .Path ,
157
186
explanation_in :str ,
158
- homework :str , msg :str ,
187
+ homework :Tuple [str ],
188
+ msg :str ,
159
189
instruction :str ,
160
190
):
161
191
result = ai_tutor .get_the_question (
@@ -165,7 +195,12 @@ def test_get_the_question(
165
195
explanation_in = explanation_in ,
166
196
).lower ()
167
197
168
- assert homework in result
198
+ assert any (
199
+ map (
200
+ lambda x : x in result ,
201
+ homework
202
+ )
203
+ )
169
204
assert msg in result
170
205
assert instruction in result
171
206
0 commit comments