diff options
author | prathamesh | 2013-07-01 15:55:26 +0530 |
---|---|---|
committer | prathamesh | 2013-07-01 15:55:26 +0530 |
commit | 33366bfa87d62d433cc7541e4699b61be78e5024 (patch) | |
tree | 6c40a5d9c7b1aacc730dca5ae263d31ccc02155a /testapp | |
parent | 041064618c290b50bd7ea213c4535b1f585d0f03 (diff) | |
download | online_test-33366bfa87d62d433cc7541e4699b61be78e5024.tar.gz online_test-33366bfa87d62d433cc7541e4699b61be78e5024.tar.bz2 online_test-33366bfa87d62d433cc7541e4699b61be78e5024.zip |
comments and print statement removed
Diffstat (limited to 'testapp')
-rw-r--r-- | testapp/test_server.py | 70 |
1 files changed, 33 insertions, 37 deletions
diff --git a/testapp/test_server.py b/testapp/test_server.py index c63ee4b..f2ea84c 100644 --- a/testapp/test_server.py +++ b/testapp/test_server.py @@ -8,22 +8,19 @@ from exam.xmlrpc_clients import code_server def check_result(result, check='correct answer'): -# if check != 'correct answer': -# assert result[0] == False -# else: -# assert result[0] == True -# if "unable to connect" in result[1].lower(): -# assert result[0], result[1] -# assert check in result[1].lower(), result[1] - print result - + if check != 'correct answer': + assert result[0] == False + else: + assert result[0] == True + if "unable to connect" in result[1].lower(): + assert result[0], result[1] + assert check in result[1].lower(), result[1] def test_python(): """Test if server runs Python code as expected.""" src = 'while True: pass' - # result = code_server.run_code(src, '', '/tmp', language="python") - # check_result(result, 'more than ') - """ + result = code_server.run_code(src, '', '/tmp', language="python") + check_result(result, 'more than ') src = 'x = 1' result = code_server.run_code(src, 'assert x == 1', '/tmp', language="python") @@ -37,7 +34,6 @@ def test_python(): result = code_server.run_code(src, 'assert x == 0', '/tmp', language="python") check_result(result, 'nameerror') - """ def test_c(): @@ -48,14 +44,14 @@ def test_c(): {return a+b;} """ result = code_server.run_code(src, 'c_cpp_files/main.cpp', '/tmp', language="C") - check_result(result) + check_result(result, 'error') src = """ int add(int a, int b) {return a+b} """ result = code_server.run_code(src, 'c_cpp_files/main.cpp', '/tmp', language="C") - check_result(result) + check_result(result, 'compilation error') src = """ int add(int a, int b) @@ -63,14 +59,14 @@ def test_c(): return a+b;} """ result = code_server.run_code(src, 'c_cpp_files/main.cpp', '/tmp', language="C") - check_result(result) + check_result(result, 'more than') src = """ int add(int a, int b) {return a+b;} """ result = code_server.run_code(src, 'c_cpp_files/main.cpp', '/tmp', language="C") - check_result(result) + check_result(result, 'correct answer') src = """ #include<stdio.h> @@ -78,7 +74,7 @@ def test_c(): {printf("All Correct");} """ result = code_server.run_code(src, 'c_cpp_files/main.cpp', '/tmp', language="C") - check_result(result) + check_result(result, 'incorrect') def test_cpp(): @@ -90,7 +86,7 @@ def test_cpp(): } """ result = code_server.run_code(src, 'c_cpp_files/main.cpp', '/tmp', language="C++") - check_result(result) + check_result(result, 'compilation error') src = """ int add(int a, int b) @@ -99,7 +95,7 @@ def test_cpp(): } """ result = code_server.run_code(src, 'c_cpp_files/main.cpp', '/tmp', language="C++") - check_result(result) + check_result(result, 'correct answer') src = """ int dd(int a, int b) @@ -108,7 +104,7 @@ def test_cpp(): } """ result = code_server.run_code(src, 'c_cpp_files/main.cpp', '/tmp', language="C++") - check_result(result) + check_result(result, 'error') src = """ int add(int a, int b) @@ -119,7 +115,7 @@ def test_cpp(): } """ result = code_server.run_code(src, 'c_cpp_files/main.cpp', '/tmp', language="C++") - check_result(result) + check_result(result, 'more than') def test_bash(): """Test if server runs Bash code as expected.""" @@ -127,41 +123,41 @@ def test_bash(): #!/bin/bash [[ $# -eq 2 ]] && echo $(( $1 + $2 )) && exit $(( $1 + $2 )) """ - # result = code_server.run_code(src, - # 'docs/sample.sh\ndocs/sample.args', '/tmp', language="bash") - # check_result(result) + result = code_server.run_code(src, + 'docs/sample.sh\ndocs/sample.args', '/tmp', language="bash") + check_result(result) src = """ #!/bin/bash [[ $# -eq 2 ]] && echo $(( $1 - $2 )) && exit $(( $1 - $2 )) """ - #result = code_server.run_code(src, - # 'docs/sample.sh\ndocs/sample.args', '/tmp', language="bash") - #check_result(result, 'error') + result = code_server.run_code(src, + 'docs/sample.sh\ndocs/sample.args', '/tmp', language="bash") + check_result(result, 'error') src = """\ #!/bin/bash while [ 1 ] ; do echo "" > /dev/null ; done """ - #result = code_server.run_code(src, - # 'docs/sample.sh\ndocs/sample.args', '/tmp', language="bash") - #check_result(result, 'more than ') + result = code_server.run_code(src, + 'docs/sample.sh\ndocs/sample.args', '/tmp', language="bash") + check_result(result, 'more than ') src = ''' #!/bin/bash while [ 1 ] ; do echo "" > /dev/null ''' - #result = code_server.run_code(src, - # 'docs/sample.sh\ndocs/sample.args', '/tmp', language="bash") - #check_result(result, 'error') + result = code_server.run_code(src, + 'docs/sample.sh\ndocs/sample.args', '/tmp', language="bash") + check_result(result, 'error') src = '''# Enter your code here. #!/bin/bash while [ 1 ] ; do echo "" > /dev/null ''' - #result = code_server.run_code(src, - # 'docs/sample.sh\ndocs/sample.args', '/tmp', language="bash") - #check_result(result, 'oserror') + result = code_server.run_code(src, + 'docs/sample.sh\ndocs/sample.args', '/tmp', language="bash") + check_result(result, 'oserror') if __name__ == '__main__': test_python() |