summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authormaheshgudi2018-04-06 16:52:45 +0530
committermaheshgudi2018-04-06 16:52:51 +0530
commit7f04851ccbb4d8b541a3ed38aa13cff36b6e898c (patch)
tree1a35de41c7d71fb8f49eb0b12328763502668752 /yaksh
parent97e6372b344f02c541e443afde5ba468506bccd8 (diff)
downloadonline_test-7f04851ccbb4d8b541a3ed38aa13cff36b6e898c.tar.gz
online_test-7f04851ccbb4d8b541a3ed38aa13cff36b6e898c.tar.bz2
online_test-7f04851ccbb4d8b541a3ed38aa13cff36b6e898c.zip
Add test cases to check if code passes without testcases
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/grader.py3
-rw-r--r--yaksh/tests/test_code_server.py15
2 files changed, 16 insertions, 2 deletions
diff --git a/yaksh/grader.py b/yaksh/grader.py
index eede4d6..c9dc8a2 100644
--- a/yaksh/grader.py
+++ b/yaksh/grader.py
@@ -131,10 +131,9 @@ class Grader(object):
# Add a new signal handler for the execution of this code.
prev_handler = create_signal_handler()
success = False
+ test_case_success_status = [False]
if len(test_case_instances) != 0:
test_case_success_status = [False] * len(test_case_instances)
- else:
- test_case_success_status = [False]
error = []
weight = 0.0
diff --git a/yaksh/tests/test_code_server.py b/yaksh/tests/test_code_server.py
index a647481..e2781df 100644
--- a/yaksh/tests/test_code_server.py
+++ b/yaksh/tests/test_code_server.py
@@ -125,6 +125,21 @@ class TestCodeServer(unittest.TestCase):
data = json.loads(result.get('result'))
self.assertFalse(data['success'])
+ # With correct answer and test case
+ testdata["metadata"]["user_answer"] = 'def f(): return 2'
+ testdata["test_case_data"] = [{'test_case': 'assert f() == 2',
+ 'test_case_type': 'standardtestcase',
+ 'weight': 0.0
+ }
+ ]
+ # When
+ submit(self.url, '0', json.dumps(testdata), '')
+ result = get_result(self.url, '0', block=True)
+
+ # Then
+ data = json.loads(result.get('result'))
+ self.assertTrue(data['success'])
+
def test_multiple_simultaneous_hits(self):
# Given
results = Queue()