diff options
author | prathamesh | 2016-11-17 13:58:51 +0530 |
---|---|---|
committer | prathamesh | 2016-11-17 13:58:51 +0530 |
commit | 93b16753ded5f3ef07187e9413c94bd52f2e77f7 (patch) | |
tree | f137a0fd2a3036c5a6e87d323d8d14ee3d480c0b /yaksh/tests/test_code_server.py | |
parent | 6ac9e99453543e6a5533f5ab77c7db3c08cc0cf9 (diff) | |
parent | aa6ed71496c4a36faed9b42104c8426345bdc2e3 (diff) | |
download | online_test-93b16753ded5f3ef07187e9413c94bd52f2e77f7.tar.gz online_test-93b16753ded5f3ef07187e9413c94bd52f2e77f7.tar.bz2 online_test-93b16753ded5f3ef07187e9413c94bd52f2e77f7.zip |
Merge branch 'master' of https://github.com/FOSSEE/online_test into student-interface
Resolved
Conflicts:
yaksh/templates/yaksh/question.html
Added testarea back for now.
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), '' ) |