示例#1
0
 def test_run(self):
     with self.assertRaises(OSError):
         coderunner.code(
             "testfiles/" + "test_c++.cpp",
             "C++",
             "testfiles/output/" + "output4.txt",
             "my_input",
         )
示例#2
0
 def test_run(self):
     source_code = "testfiles/" + "test_c++.cpp"
     language = "C++"
     output = "testfiles/output/" + "output8.txt"
     r = coderunner.code(source_code, language, output)
     r.run()
     self.assertEqual(r.getStatus(), "Accepted", "Something Wrong")
示例#3
0
 def test_run(self):
     source_code = "print(\"This will return Wrong Answer\")"
     language = "Python3"
     output = "Wrong Answer"
     r = coderunner.code(source_code, language, output, path=False)
     r.run()
     self.assertEqual(r.getStatus(), "Wrong Answer", "Something Wrong")
示例#4
0
 def test_run(self):
     source_code = 'print("This will return Wrong Answer")'
     language = "Python3"
     output = "Wrong Answer"
     r = coderunner.code(source_code, language, output, path=False)
     with self.assertRaises(ValueTooLargeError):
         r.setArguments("qw" * 70)
示例#5
0
 def test_run(self):
     source_code = 'print("This will return Wrong Answer")'
     language = "Python3"
     output = "Wrong Answer"
     r = coderunner.code(source_code, language, output, path=False)
     with self.assertRaises(InvalidURL):
         r.api(key="ABCHE", url="ghthth")
示例#6
0
 def test_run(self):
     source_code = "testfiles/" + "test_c_input.c"
     language = "C"
     output = "testfiles/output/" + "output3.txt"
     Input = "testfiles/input/" + "input2.txt"
     r = coderunner.code(source_code, language, output, Input)
     r.run()
     self.assertEqual(r.getStatus(), "Accepted", "Something Wrong")
示例#7
0
def RunCode(request):
    SourceCode = request.POST.get('source')
    Language = request.POST.get('lang')
    if (request.POST.get('input') != ''):
        input_data = request.POST.get('input')
        r = code(SourceCode, Language, inp=input_data, path=False)
        r.run()
    else:
        r = code(SourceCode, Language, path=False)
        r.run()
    cstat = r.getStatus()
    rstat = "Running"
    time = r.getTime()
    memory = r.getMemory()
    out = r.getOutput()
    if (cstat == "Accepted"):
        data = {
            'cstat': cstat,
            'rstat': rstat,
            'time': time,
            'memory': memory,
            'output': out
        }
        return JsonResponse(data)

    else:
        err = r.getError()
        data = {
            'cstat': cstat,
            'rstat': rstat,
            'time': time,
            'memory': memory,
            'output': out,
            'error': err
        }
        print(data)
        return JsonResponse(data)
示例#8
0
 def test_run(self):
     with self.assertRaises(OSError):
         coderunner.code("testfiles/" + "test_c++.cpp", "C++",
                         "Hello World")
示例#9
0
 def test_run(self):
     with self.assertRaises(OSError):
         coderunner.code("Hello World", "C++", "Hello World")
示例#10
0
 def test_run(self):
     with self.assertRaises(ValueError):
         coderunner.code("Hello World", "fgbh", "Hello World", path=False)
示例#11
0
from coderunner import coderunner
import pprint

source_code = "testfiles/" + "test_python_input.py"
language = "Python3"
output = "testfiles/output/" + "output2.txt"
Input = "testfiles/input/" + "input.txt"
r = coderunner.code(source_code, language, output, Input)

r2 = coderunner.code("print(\"yo\")", "Python3", "YO", path=False)

# run the code
r.run()

print("Run r :")
print("Status : " + r.getStatus())

r2.run()

print("Run r2 :")
print("Status : " + r2.getStatus())

# check if any error occured
if r.getError() is not None:
    pprint.pprint("Error : " + r.getError())
else:
    print("Standard Output : ")
    pprint.pprint(r.getOutput())
print("Execution Time : " + r.getTime())
print("Memory : " + str(r.getMemory()))
示例#12
0
from coderunner import coderunner
import os

from dotenv import load_dotenv
load_dotenv()

source_code = "testfiles/" + "test_python_input.py"
language = "Python3"
output = "testfiles/output/" + "output2.txt"
Input = "testfiles/input/" + "input.txt"

API_KEY = os.environ["API_KEY"]

r = coderunner.code(source_code, language, output, Input)

# Necessary step to initialize API keys & URL
r.api(key=API_KEY)

# run the code
r.run()

print("Running r :")
print("Status : " + r.getStatus())
print("Output : " + r.getOutput())
示例#13
0
from coderunner.coderunner import code
import os

source_code = "./pyt.py"
language = "Python3"
expected_output = "11"
standard_input = "11"

# use this if you have a standard input to Program
r = code(source_code, language, expected_output, standard_input)