2222
2323
2424@pytest .fixture
25- def json_dict () -> Dict [str , Union [str , List ]]:
26- with open (test_folder / 'sample_report.json' , 'r' ) as f :
25+ def sample_report_path () -> pathlib .Path :
26+ return test_folder / 'sample_report.json'
27+
28+
29+ @pytest .fixture
30+ def json_dict (sample_report_path ) -> Dict [str , Union [str , List ]]:
31+ with sample_report_path .open ('rt' ) as f :
2732 result = json .load (f )
2833 return result
2934
@@ -35,8 +40,13 @@ def test_collect_longrepr(json_dict):
3540
3641
3742@pytest .fixture
38- def json_dict_div_zero_try_except () -> Dict [str , Union [str , List ]]:
39- with open (test_folder / 'json_dict_div_zero_try_except.json' , 'r' ) as f :
43+ def div_zero_report_path () -> pathlib .Path :
44+ return test_folder / 'json_dict_div_zero_try_except.json'
45+
46+
47+ @pytest .fixture
48+ def json_dict_div_zero_try_except (div_zero_report_path :pathlib .Path ) -> Dict [str , Union [str , List ]]:
49+ with div_zero_report_path .open ('rt' ) as f :
4050 result = json .load (f )
4151 return result
4252
@@ -139,5 +149,26 @@ def test_get_code_instruction(
139149 assert instruction in result
140150
141151
152+ def test_get_the_question (
153+ sample_report_path :pathlib .Path ,
154+ div_zero_report_path :pathlib .Path ,
155+ sample_student_code_path :pathlib .Path ,
156+ sample_readme_path :pathlib .Path ,
157+ human_language :str ,
158+ homework :str , msg :str ,
159+ instruction :str ,
160+ ):
161+ result = ai_tutor .get_the_question (
162+ report_paths = (sample_report_path ,div_zero_report_path ),
163+ student_files = (sample_student_code_path ,),
164+ readme_file = sample_readme_path ,
165+ human_language = human_language ,
166+ ).lower ()
167+
168+ assert homework in result
169+ assert msg in result
170+ assert instruction in result
171+
172+
142173if '__main__' == __name__ :
143174 pytest .main ([__file__ ])
0 commit comments