Skip to content

Commit 1ed5b1b

Browse files
committed
Add integration test for validating JIT builds of Python
1 parent 0c64b8e commit 1ed5b1b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/test_integration.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,33 @@ def test_gil_status(self):
103103
self.assertEqual(status, 200)
104104
self.assertEqual(json.loads(response)["stdout"], expected)
105105

106+
def test_jit_status(self):
107+
"""Tests that JIT builds have the JIT available and enabled."""
108+
with run_gunicorn():
109+
get_jit_status = {"input": "import sys; print(sys._jit.is_enabled())"}
110+
111+
# This test will only work on tests where the sys._jit namespace exists.
112+
#
113+
# The namespace was added in 3.14 but is not guaranteed to be there for other
114+
# implementations of Python, see https://docs.python.org/3/library/sys.html#sys._jit
115+
# for full information.
116+
#
117+
# For now, the two below test cases are guaranteed to have the sys._jit module available
118+
# and (if compiled correctly) should return the below values.
119+
cases = [
120+
("3.14", "False\n"),
121+
("3.14j", "True\n"),
122+
]
123+
for version, expected in cases:
124+
with self.subTest(version=version, expected=expected):
125+
payload = {
126+
"executable_path": f"/snekbin/python/{version}/bin/python",
127+
**get_jit_status,
128+
}
129+
response, status = snekbox_request(payload)
130+
self.assertEqual(status, 200)
131+
self.assertEqual(json.loads(response)["stdout"], expected)
132+
106133
def invalid_executable_paths(self):
107134
"""Test that passing invalid executable paths result in no code execution."""
108135
with run_gunicorn():

0 commit comments

Comments
 (0)