Skip to content

Commit fbeea20

Browse files
committed
support for ignoring expected output
1 parent fbd1bb5 commit fbeea20

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

coderunner/coderunner.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,12 @@ class code:
7171
"""
7272

7373
def __init__(
74-
self, source: str, lang: str, output: str, inp: str = None, path: bool = True
74+
self,
75+
source: str,
76+
lang: str,
77+
output: str = None,
78+
inp: str = None,
79+
path: bool = True,
7580
):
7681

7782
self.path = path
@@ -90,7 +95,7 @@ def __init__(
9095
raise OSError(f"{source} is not a valid file path")
9196
self.source = source
9297

93-
if not os.path.exists(output):
98+
if output is not None and not os.path.exists(output):
9499
raise OSError(f"{output} is not a valid file path")
95100
self.output = output
96101

@@ -149,8 +154,9 @@ def __readStatus(self, token: str):
149154
def __submit(self):
150155
if self.inp is not None:
151156
api_params["stdin"] = self.inp
157+
if self.output is not None:
158+
api_params["expected_output"] = self.output
152159

153-
api_params["expected_output"] = self.output
154160
api_params["language_id"] = self.language_id
155161
api_params["source_code"] = self.source
156162

@@ -214,8 +220,9 @@ def run(self, number_of_runs: int = 1):
214220
if self.path:
215221
if self.inp is not None:
216222
self.inp = self.__readStandardInput()
223+
if self.output is not None:
224+
self.output = self.__readExpectedOutput()
217225
self.source = self.__readCode()
218-
self.output = self.__readExpectedOutput()
219226

220227
token = self.__submit()
221228
self.__token = token

0 commit comments

Comments
 (0)