Skip to content

Commit 15c551c

Browse files
committed
minor changes
1 parent 458a719 commit 15c551c

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

CodeRunner/run.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@
2727

2828
class coderunner:
2929

30-
def __init__(self, program_name, lang, output, inp = None):
30+
def __init__(self, program_name: str, lang: str, output: str, inp: str = None):
3131
self.program_name = program_name
3232
self.lang = lang
33+
if lang not in languages:
34+
raise ValueError(f"{lang} is not a supported languige {languages.keys()}")
35+
3336
self.output = output
3437
self.inp = inp
3538
self.language_id = languages[lang]
@@ -55,7 +58,7 @@ def __readStandardInput(self):
5558
return data
5659

5760

58-
def __readStatus(self, token):
61+
def __readStatus(self, token: str):
5962
"""
6063
Check Submission status
6164
"""

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,21 @@ python3 tests.py
2323
### Usage
2424

2525
```python
26-
import CodeRunner.run as cr
26+
from CodeRunner import run
27+
import pprint
2728

2829
program_name = "testfiles/" + "test_python.py"
29-
language = "Python"
30+
language = "C#"
3031
output = "testfiles/" + "output2.txt"
3132
Input = "testfiles/" + "input.txt"
32-
r = cr.coderunner(program_name, language, output, Input)
33+
r = run.coderunner(program_name, language, output, Input)
3334

3435
print("Status : " + r.run())
3536
if r.getError() != None:
36-
print("Error : " + r.getError())
37+
pprint.pprint("Error : " + r.getError())
3738
else:
38-
print("stdout : " + r.getStandardOutput())
39+
print("Standard Output : ")
40+
pprint.pprint(r.getStandardOutput())
3941
print("Execution Time : " + r.getTime())
4042
print("Memory : " + str(r.getMemory()))
4143
```

demo.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
import CodeRunner.run as cr
1+
from CodeRunner import run
2+
import pprint
23

34
program_name = "testfiles/" + "test_python.py"
4-
language = "Python"
5+
language = "C#"
56
output = "testfiles/" + "output2.txt"
67
Input = "testfiles/" + "input.txt"
7-
r = cr.coderunner(program_name, language, output, Input)
8+
r = run.coderunner(program_name, language, output, Input)
89

910
print("Status : " + r.run())
1011
if r.getError() != None:
11-
print("Error : " + r.getError())
12+
pprint.pprint("Error : " + r.getError())
1213
else:
13-
print("stdout : " + r.getStandardOutput())
14+
print("Standard Output : ")
15+
pprint.pprint(r.getStandardOutput())
1416
print("Execution Time : " + r.getTime())
1517
print("Memory : " + str(r.getMemory()))

tests.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import unittest
2-
import CodeRunner.run as cr
2+
from CodeRunner import run
33

44
#test for Java program
55
class TestRunA(unittest.TestCase):
66
def test_run(self):
77
program_name = "testfiles/" + "test_java.java"
88
language = "Java"
99
output = "testfiles/" + "output.txt"
10-
r = cr.coderunner(program_name, language, output)
10+
r = run.coderunner(program_name, language, output)
1111
self.assertEqual(r.run(),
1212
"Accepted", "Something Wrong")
1313

@@ -18,7 +18,7 @@ def test_run(self):
1818
language = "Python"
1919
output = "testfiles/" + "output2.txt"
2020
Input = "testfiles/" + "input.txt"
21-
r = cr.coderunner(program_name, language, output, Input)
21+
r = run.coderunner(program_name, language, output, Input)
2222
self.assertEqual(r.run(),
2323
"Accepted", "Something Wrong")
2424

@@ -29,7 +29,7 @@ def test_run(self):
2929
language = "C"
3030
output = "testfiles/" + "output3.txt"
3131
Input = "testfiles/" + "input2.txt"
32-
r = cr.coderunner(program_name, language, output, Input)
32+
r = run.coderunner(program_name, language, output, Input)
3333
self.assertEqual(r.run(),
3434
"Accepted", "Something Wrong")
3535

@@ -40,7 +40,7 @@ def test_run(self):
4040
language = "C++"
4141
output = "testfiles/" + "output4.txt"
4242
Input = "testfiles/" + "input3.txt"
43-
r = cr.coderunner(program_name, language, output, Input)
43+
r = run.coderunner(program_name, language, output, Input)
4444
self.assertEqual(r.run(),
4545
"Accepted", "Something Wrong")
4646

0 commit comments

Comments
 (0)