aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ionite34 <[email protected]>2022-11-28 12:24:59 +0800
committerGravatar ionite34 <[email protected]>2022-11-28 12:24:59 +0800
commitad7082e6a5c4462e5064fbf3848bf61ba5c22fdf (patch)
tree85afb1619cca8e73e5c7cb373d7f1a299b03905a
parentAdd input/args integration test (diff)
Fix input append to args
-rw-r--r--snekbox/api/resources/eval.py1
-rw-r--r--tests/test_integration.py4
2 files changed, 3 insertions, 2 deletions
diff --git a/snekbox/api/resources/eval.py b/snekbox/api/resources/eval.py
index c3e553a..28b739d 100644
--- a/snekbox/api/resources/eval.py
+++ b/snekbox/api/resources/eval.py
@@ -122,6 +122,7 @@ class EvalResource:
# If `input` is supplied, default `args` to `-c`
if "input" in body:
body.setdefault("args", ["-c"])
+ body["args"].append(body["input"])
try:
result = self.nsjail.python3(
py_args=body["args"],
diff --git a/tests/test_integration.py b/tests/test_integration.py
index 5aa1b43..01fa657 100644
--- a/tests/test_integration.py
+++ b/tests/test_integration.py
@@ -56,8 +56,8 @@ class IntegrationTests(unittest.TestCase):
"""Test normal eval requests without files."""
with run_gunicorn():
cases = [
- ({"input": "print('Hello')"}, "Hello"),
- ({"args": ["-c", "print('Hello')"]}, "Hello"),
+ ({"input": "print('Hello')"}, "Hello\n"),
+ ({"args": ["-c", "print('abc12')"]}, "abc12\n"),
]
for body, expected in cases:
with self.subTest(body=body):