@@ -660,7 +660,7 @@ def test_nohighlight_too_few_calls(self):
660660 self .assertEqual (sct_payload .get ('line_start' ), None )
661661
662662
663- class TestFunctionWithFunctionArg (unittest .TestCase ):
663+ class TestFunctionComplexArgs (unittest .TestCase ):
664664 def setUp (self ):
665665 self .data = {
666666 "DC_SOLUTION" : """
@@ -671,22 +671,37 @@ def apply(f, arr): return f(arr)
671671apply(sum2, [1,2,3])
672672""" ,
673673 "DC_SCT" : """
674- def sum2(arr): return sum(arr)
675674test_function('apply')
676675"""
677676 }
678677 self .data ["DC_CODE" ] = self .data ["DC_SOLUTION" ]
679678
680- @unittest .skip ("Can't unpickle user def funcs, but doesn't throw PicklingError (see issue #155)" )
681- def test_pass (self ):
679+ def test_function_with_funcarg_fails (self ):
680+ # because functions are shipped across student and submission processes
681+ # they are always "unequal".
682682 sct_payload = helper .run (self .data )
683- self .assertTrue (sct_payload ['correct' ])
683+ self .assertFalse (sct_payload ['correct' ])
684684
685- def test_pass_v2 (self ):
685+ def test_pass_with_no_eval (self ):
686686 self .data ["DC_SCT" ] = """test_function_v2('apply', params=['f', 'arr'], do_eval=[False, True])"""
687687 sct_payload = helper .run (self .data )
688688 self .assertTrue (sct_payload ['correct' ])
689689
690+ def test_fail_undillable_args (self ):
691+ self .data = {
692+ "DC_PEC" : """
693+ import pickle; from io import BytesIO
694+
695+ file = BytesIO(pickle.dumps('abc'))
696+ """ ,
697+ "DC_SOLUTION" : "d = pickle.load(file); print(d)" ,
698+ "DC_CODE" : "print(file)" ,
699+ "DC_SCT" : """test_function("print", index=1)"""
700+ }
701+ sct_payload = helper .run (self .data )
702+ self .assertFalse (sct_payload ['correct' ])
703+
704+
690705
691706
692707if __name__ == "__main__" :
0 commit comments