load("@rules_shell//shell:sh_test.bzl", "sh_test") load("//src/workerd/server/tests/python:import_tests.bzl", "gen_rust_import_tests") load("//src/workerd/server/tests/python:py_wd_test.bzl", "py_wd_test", "python_test_setup") load("//src/workerd/server/tests/python/vendor_pkg_tests:vendor_test.bzl", "vendored_py_wd_test") python_test_setup() # NOTE: Each test takes a while to start up, so if possible add additional tests to pytest or to # top-level-tests or sdk or some other existing test. # TODO: This only works for pytest-asyncio <= 1.1.0, starting from pytest-asyncio 1.2.0 there is a # problem. vendored_py_wd_test( "pytest-asyncio", data = glob(["pytest/tests/**"]), level = 0, main_py_file = "pytest/main.py", test_template = "pytest/pytest.wd-test", ) py_wd_test("hello") py_wd_test("top-level-tests") py_wd_test("env-param") py_wd_test("asgi") py_wd_test("asgi-sse") py_wd_test("random") py_wd_test("subdirectory") py_wd_test( "sdk", compat_date = "2026-01-01", ) gen_rust_import_tests() py_wd_test("undefined-handler") py_wd_test("vendor_dir") py_wd_test("dont-snapshot-pyodide") py_wd_test("filter-non-py-files") py_wd_test("durable-object") py_wd_test( "durable-object-websocket", make_snapshot = False, # TODO: enabling this will reproduce a strange issue, see comment in EW-9767. use_snapshot = None, ) py_wd_test("worker-entrypoint") py_wd_test( "jspi", skip_python_flags = ["0.26.0a2"], ) py_wd_test("python-rpc") py_wd_test("workflow-entrypoint") py_wd_test("vendor_dir_compat_flag") py_wd_test("default-class-with-legacy-global-handlers") py_wd_test( "fastapi", make_snapshot = False, use_snapshot = "fastapi", ) py_wd_test( "numpy", make_snapshot = False, use_snapshot = "numpy", ) py_wd_test("python-compat-flag") py_wd_test("pth-file") # Shell-driven test for the python-abort-isolate-on-fatal-error autogate. The Python worker # triggers a fatal error which (with the autogate enabled) calls abortIsolate(), terminating the # workerd process. The shell script verifies the expected fatal output and non-zero exit. sh_test( name = "python-abort-isolate-on-fatal-test", size = "enormous", srcs = ["python-abort-isolate-on-fatal/python-abort-isolate-on-fatal.sh"], args = [ "$(location //src/workerd/server:workerd_cross)", "$(location python-abort-isolate-on-fatal/python-abort-isolate-on-fatal.wd-test)", "$(location //src/workerd/server/tests/python:pyodide_dev.capnp.bin@rule)", "../+pyodide+all_pyodide_wheels_20250808", ], data = [ "python-abort-isolate-on-fatal/python-abort-isolate-on-fatal.wd-test", "python-abort-isolate-on-fatal/worker.py", "//src/workerd/server:workerd_cross", "//src/workerd/server/tests/python:pyodide_dev.capnp.bin@rule", "@all_pyodide_wheels_20250808//:whls", ], tags = [ "no-coverage", "python", ], target_compatible_with = select({ "@platforms//os:windows": ["@platforms//:incompatible"], "//conditions:default": [], }), )