@@ -312,24 +312,16 @@ def _check_result(submission_id):
312312 return result
313313
314314
315- def test_solution (slug , filetype , code = None ):
315+ def test_solution (problem_id , title , slug , filetype , code , test_input ):
316316 assert is_login ()
317- problem = get_problem (slug )
318- if not problem :
319- return None
320-
321- if not problem ['testable' ]:
322- _echoerr ('the problem is not testable, please submit directly' )
323- return None
324317
325- if code is None :
326- code = '\n ' .join (vim .current .buffer )
318+ code = _remove_description (code )
327319
328320 headers = _make_headers ()
329321 headers ['Referer' ] = LC_PROBLEM .format (slug = slug )
330- body = {'data_input' : problem [ 'testcase' ] ,
322+ body = {'data_input' : test_input ,
331323 'lang' : filetype ,
332- 'question_id' : str (problem [ 'id' ] ),
324+ 'question_id' : str (problem_id ),
333325 'test_mode' : False ,
334326 'typed_code' : code }
335327 url = LC_TEST .format (slug = slug )
@@ -345,25 +337,27 @@ def test_solution(slug, filetype, code=None):
345337
346338 actual = _check_result (res .json ()['interpret_id' ])
347339 expected = _check_result (res .json ()['interpret_expected_id' ])
348- actual ['testcase' ] = problem [ 'testcase' ] .split ('\n ' )
340+ actual ['testcase' ] = test_input .split ('\n ' )
349341 actual ['expected_answer' ] = expected ['answer' ]
350- actual ['title' ] = problem [ ' title' ]
342+ actual ['title' ] = title
351343 return actual
352344
353345
354- def test_solution_async (slug , filetype , code = None ):
346+ def test_solution_async (problem_id , title , slug , filetype , code , test_input ):
355347 assert is_login ()
356348 global task_input , task_name
357349 if task_running :
358350 _echoerr ('there is other task running: ' + task_name )
359351 return False
360352
361- if code is None :
362- code = ' \n ' . join ( vim . current . buffer )
353+ log . info ( ' code %s' , code )
354+
363355 code = _remove_description (code )
364356
357+ log .info ('code removed %s' , code )
358+
365359 task_name = 'test_solution'
366- task_input = [slug , filetype , code ]
360+ task_input = [problem_id , title , slug , filetype , code , test_input ]
367361 task_trigger .release ()
368362 return True
369363
@@ -591,7 +585,7 @@ def get_problems_of_topic(topic_slug):
591585
592586 if not topic_tag :
593587 return {'topic_name' : topic_slug , 'problems' : []}
594-
588+
595589 if topic_tag ['frequencies' ]:
596590 id_to_frequency_map = json .loads (topic_tag ['frequencies' ])
597591 else :
@@ -684,7 +678,7 @@ def process_problem(p):
684678 'ac_rate' : stats ['totalAcceptedRaw' ] / stats ['totalSubmissionRaw' ],
685679 'level' : p ['difficulty' ],
686680 'favor' : False ,
687- 'frequencies' : id_to_frequency_map .get (p ['questionId' ],
681+ 'frequencies' : id_to_frequency_map .get (p ['questionId' ],
688682 EMPTY_FREQUENCIES )[4 :]}
689683
690684 return {
@@ -704,11 +698,9 @@ def _thread_main():
704698 log .info ('task thread input: name="%s" input="%s"' , task_name , task_input )
705699 try :
706700 if task_name == 'test_solution' :
707- slug , file_type , code = task_input
708- task_output = test_solution (slug , file_type , code )
701+ task_output = test_solution (* task_input )
709702 elif task_name == 'submit_solution' :
710- slug , file_type , code = task_input
711- task_output = submit_solution (slug , file_type , code )
703+ task_output = submit_solution (* task_input )
712704 except BaseException as e :
713705 task_err = str (e )
714706 log .info ('task thread output: name="%s" output="%s" error="%s"' , task_name , task_output ,
0 commit comments