Skip to content

Commit 01c7a08

Browse files
committed
unit tests for unpickling error issue #155
1 parent 8689abe commit 01c7a08

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

tests/test_test_function.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,34 @@ def test_nohighlight_too_few_calls(self):
660660
self.assertEqual(sct_payload.get('line_start'), None)
661661

662662

663+
class TestFunctionWithFunctionArg(unittest.TestCase):
664+
def setUp(self):
665+
self.data = {
666+
"DC_SOLUTION": """
667+
def sum2(arr): return sum(arr)
668+
669+
def apply(f, arr): return f(arr)
670+
671+
apply(sum2, [1,2,3])
672+
""",
673+
"DC_SCT": """
674+
def sum2(arr): return sum(arr)
675+
test_function('apply')
676+
"""
677+
}
678+
self.data["DC_CODE"] = self.data["DC_SOLUTION"]
679+
680+
@unittest.skip("Can't unpickle user def funcs, but doesn't throw PicklingError (see issue #155)")
681+
def test_pass(self):
682+
sct_payload = helper.run(self.data)
683+
self.assertTrue(sct_payload['correct'])
684+
685+
def test_pass_v2(self):
686+
self.data["DC_SCT"] = """test_function_v2('apply', params=['f', 'arr'], do_eval=[False, True])"""
687+
sct_payload = helper.run(self.data)
688+
self.assertTrue(sct_payload['correct'])
689+
690+
663691

664692
if __name__ == "__main__":
665693
unittest.main()

0 commit comments

Comments
 (0)