def test_run(self): with self.assertRaises(OSError): coderunner.code( "testfiles/" + "test_c++.cpp", "C++", "testfiles/output/" + "output4.txt", "my_input", )
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")
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")
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)
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")
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")
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)
def test_run(self): with self.assertRaises(OSError): coderunner.code("testfiles/" + "test_c++.cpp", "C++", "Hello World")
def test_run(self): with self.assertRaises(OSError): coderunner.code("Hello World", "C++", "Hello World")
def test_run(self): with self.assertRaises(ValueError): coderunner.code("Hello World", "fgbh", "Hello World", path=False)
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()))
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())
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)