refactor: update codejail test condition (#32955)

Skip the test for codejail if the codejailservice api is not enabled.
It fixes running this test case in Tutor.
This commit is contained in:
Babatunde Olusola
2023-09-07 16:08:30 +01:00
committed by GitHub
parent 750ee00353
commit 6e2c43e4e0

View File

@@ -19,6 +19,7 @@ from six import unichr
from six.moves import range
from xmodule.capa.safe_exec import safe_exec, update_hash
from xmodule.capa.safe_exec.remote_exec import is_codejail_rest_service_enabled
class TestSafeExec(unittest.TestCase): # lint-amnesty, pylint: disable=missing-class-docstring
@@ -87,7 +88,11 @@ class TestSafeOrNot(unittest.TestCase): # lint-amnesty, pylint: disable=missing
'''
# Can't test for forbiddenness if CodeJail isn't configured for python.
if not jail_code.is_configured("python"):
pytest.skip()
# Can't test for forbiddenness if CodeJail rest service isn't enabled.
# Remote codejailservice must be running, see https://github.com/eduNEXT/tutor-contrib-codejail/
if not is_codejail_rest_service_enabled():
pytest.skip(reason="Local or remote codejail has to be configured and enabled to run this test.")
g = {}
with pytest.raises(SafeExecException) as cm: