From 6e2c43e4e06452ad58dd6f0ce2eef526dc0db7ac Mon Sep 17 00:00:00 2001 From: Babatunde Olusola Date: Thu, 7 Sep 2023 16:08:30 +0100 Subject: [PATCH] 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. --- xmodule/capa/safe_exec/tests/test_safe_exec.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xmodule/capa/safe_exec/tests/test_safe_exec.py b/xmodule/capa/safe_exec/tests/test_safe_exec.py index 01e6204cbd..0f6429ec5e 100644 --- a/xmodule/capa/safe_exec/tests/test_safe_exec.py +++ b/xmodule/capa/safe_exec/tests/test_safe_exec.py @@ -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: