aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2023-03-18 01:53:15 +0400
committerGravatar Hassan Abouelela <[email protected]>2023-03-18 01:53:15 +0400
commite3943f5f27184e1f83ced0b3e3396a9e4a4ba381 (patch)
tree4630579f00c0296c27ba5db689d12ddb701f93d4
parentAdd More Information To Version Display Names (diff)
Update Failing Tests
Signed-off-by: Hassan Abouelela <[email protected]>
-rw-r--r--snekbox/nsjail.py4
-rw-r--r--tests/test_integration.py3
-rw-r--r--tests/test_nsjail.py8
3 files changed, 10 insertions, 5 deletions
diff --git a/snekbox/nsjail.py b/snekbox/nsjail.py
index d367482..ce218ba 100644
--- a/snekbox/nsjail.py
+++ b/snekbox/nsjail.py
@@ -9,7 +9,7 @@ from typing import Iterable, TypeVar
from google.protobuf import text_format
-from scripts.python_version import Version
+from scripts.python_version import MAIN_VERSION, Version
from snekbox import DEBUG, utils
from snekbox.config_pb2 import NsJailConfig
from snekbox.filesystem import Size
@@ -178,7 +178,7 @@ class NsJail:
def python3(
self,
py_args: Iterable[str],
- version: Version,
+ version: Version = MAIN_VERSION,
files: Iterable[FileAttachment] = (),
nsjail_args: Iterable[str] = (),
) -> EvalResult:
diff --git a/tests/test_integration.py b/tests/test_integration.py
index 91b01e6..aa21a2d 100644
--- a/tests/test_integration.py
+++ b/tests/test_integration.py
@@ -7,6 +7,8 @@ from textwrap import dedent
from tests.gunicorn_utils import run_gunicorn
+from scripts.python_version import MAIN_VERSION
+
def b64encode_code(data: str):
data = dedent(data).strip()
@@ -95,6 +97,7 @@ class IntegrationTests(unittest.TestCase):
expected = {
"stdout": "hello\n",
"returncode": 0,
+ "version": MAIN_VERSION.display_name,
"files": [
{
"path": "dir/test2.txt",
diff --git a/tests/test_nsjail.py b/tests/test_nsjail.py
index 456046b..d59a6ce 100644
--- a/tests/test_nsjail.py
+++ b/tests/test_nsjail.py
@@ -9,6 +9,7 @@ from itertools import product
from pathlib import Path
from textwrap import dedent
+from scripts.python_version import MAIN_VERSION
from snekbox.filesystem import Size
from snekbox.nsjail import NsJail
from snekbox.snekio import FileAttachment
@@ -24,11 +25,11 @@ class NsJailTests(unittest.TestCase):
self.logger.setLevel(logging.WARNING)
def eval_code(self, code: str):
- return self.nsjail.python3(["-c", code])
+ return self.nsjail.python3(["-c", code], MAIN_VERSION)
def eval_file(self, code: str, name: str = "test.py", **kwargs):
file = FileAttachment(name, code.encode())
- return self.nsjail.python3([name], [file], **kwargs)
+ return self.nsjail.python3([name], MAIN_VERSION, [file], **kwargs)
def test_print_returns_0(self):
for fn in (self.eval_code, self.eval_file):
@@ -64,7 +65,7 @@ class NsJailTests(unittest.TestCase):
FileAttachment("lib.py", "x = 'hello'".encode()),
]
- result = self.nsjail.python3(["main.py"], files)
+ result = self.nsjail.python3(["main.py"], MAIN_VERSION, files)
self.assertEqual(result.returncode, 0)
self.assertEqual(result.stdout, "hello\n")
self.assertEqual(result.stderr, None)
@@ -231,6 +232,7 @@ class NsJailTests(unittest.TestCase):
"""Test errors during file write."""
result = self.nsjail.python3(
[""],
+ MAIN_VERSION,
[
FileAttachment("dir/test.txt", b"abc"),
FileAttachment("dir", b"xyz"),