diff options
author | Prabhu Ramachandran | 2016-11-17 12:54:56 +0530 |
---|---|---|
committer | GitHub | 2016-11-17 12:54:56 +0530 |
commit | aa6ed71496c4a36faed9b42104c8426345bdc2e3 (patch) | |
tree | e5ff410809c60e735cc1a64ce667ba1d4caa6cf5 /yaksh/tests/test_code_server.py | |
parent | 7ae8584a4f4d095e005d6239102c0f26611ac006 (diff) | |
parent | c4a39baa980578b4e35452d7e1978b1bf0b38e13 (diff) | |
download | online_test-aa6ed71496c4a36faed9b42104c8426345bdc2e3.tar.gz online_test-aa6ed71496c4a36faed9b42104c8426345bdc2e3.tar.bz2 online_test-aa6ed71496c4a36faed9b42104c8426345bdc2e3.zip |
Merge pull request #152 from ankitjavalkar/partial
Partial Grading
Diffstat (limited to 'yaksh/tests/test_code_server.py')
-rw-r--r-- | yaksh/tests/test_code_server.py | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/yaksh/tests/test_code_server.py b/yaksh/tests/test_code_server.py index 8835110..7efd20b 100644 --- a/yaksh/tests/test_code_server.py +++ b/yaksh/tests/test_code_server.py @@ -35,10 +35,14 @@ class TestCodeServer(unittest.TestCase): def setUp(self): self.code_server = CodeServerProxy() - def test_inifinite_loop(self): + def test_infinite_loop(self): # Given testdata = {'user_answer': 'while True: pass', - 'test_case_data': [{'test_case':'assert 1==2'}]} + 'partial_grading': False, + 'test_case_data': [{'test_case':'assert 1==2', + 'weight': 0.0 + } + ]} # When result = self.code_server.run_code( @@ -53,7 +57,11 @@ class TestCodeServer(unittest.TestCase): def test_correct_answer(self): # Given testdata = {'user_answer': 'def f(): return 1', - 'test_case_data': [{'test_case':'assert f() == 1'}]} + 'partial_grading': False, + 'test_case_data': [{'test_case':'assert f() == 1', + 'weight': 0.0 + } + ]} # When result = self.code_server.run_code( @@ -63,12 +71,16 @@ class TestCodeServer(unittest.TestCase): # Then data = json.loads(result) self.assertTrue(data['success']) - self.assertEqual(data['error'], 'Correct answer') + self.assertIn('Correct answer', data['error']) def test_wrong_answer(self): # Given testdata = {'user_answer': 'def f(): return 1', - 'test_case_data': [{'test_case':'assert f() == 2'}]} + 'partial_grading': False, + 'test_case_data': [{'test_case':'assert f() == 2', + 'weight': 0.0 + } + ]} # When result = self.code_server.run_code( @@ -87,7 +99,11 @@ class TestCodeServer(unittest.TestCase): def run_code(): """Run an infinite loop.""" testdata = {'user_answer': 'while True: pass', - 'test_case_data': [{'test_case':'assert 1==2'}]} + 'partial_grading': False, + 'test_case_data': [{'test_case':'assert 1==2', + 'weight': 0.0 + } + ]} result = self.code_server.run_code( 'python', 'standardtestcase', json.dumps(testdata), '' ) |