File
Blob: src/workerd/server/tests/python/BUILD.bazel
| 1 | load("@rules_shell//shell:sh_test.bzl", "sh_test") |
| 2 | load("//src/workerd/server/tests/python:import_tests.bzl", "gen_rust_import_tests") |
| 3 | load("//src/workerd/server/tests/python:py_wd_test.bzl", "py_wd_test", "python_test_setup") |
| 4 | load("//src/workerd/server/tests/python/vendor_pkg_tests:vendor_test.bzl", "vendored_py_wd_test") |
| 5 | |
| 6 | python_test_setup() |
| 7 | |
| 8 | # NOTE: Each test takes a while to start up, so if possible add additional tests to pytest or to |
| 9 | # top-level-tests or sdk or some other existing test. |
| 10 | |
| 11 | # TODO: This only works for pytest-asyncio <= 1.1.0, starting from pytest-asyncio 1.2.0 there is a |
| 12 | # problem. |
| 13 | vendored_py_wd_test( |
| 14 | "pytest-asyncio", |
| 15 | data = glob(["pytest/tests/**"]), |
| 16 | level = 0, |
| 17 | main_py_file = "pytest/main.py", |
| 18 | test_template = "pytest/pytest.wd-test", |
| 19 | ) |
| 20 | |
| 21 | py_wd_test("hello") |
| 22 | |
| 23 | py_wd_test("top-level-tests") |
| 24 | |
| 25 | py_wd_test("env-param") |
| 26 | |
| 27 | py_wd_test("asgi") |
| 28 | |
| 29 | py_wd_test("asgi-sse") |
| 30 | |
| 31 | py_wd_test("random") |
| 32 | |
| 33 | py_wd_test("subdirectory") |
| 34 | |
| 35 | py_wd_test( |
| 36 | "sdk", |
| 37 | compat_date = "2026-01-01", |
| 38 | ) |
| 39 | |
| 40 | gen_rust_import_tests() |
| 41 | |
| 42 | py_wd_test("undefined-handler") |
| 43 | |
| 44 | py_wd_test("vendor_dir") |
| 45 | |
| 46 | py_wd_test("dont-snapshot-pyodide") |
| 47 | |
| 48 | py_wd_test("filter-non-py-files") |
| 49 | |
| 50 | py_wd_test("durable-object") |
| 51 | |
| 52 | py_wd_test( |
| 53 | "durable-object-websocket", |
| 54 | make_snapshot = False, |
| 55 | # TODO: enabling this will reproduce a strange issue, see comment in EW-9767. |
| 56 | use_snapshot = None, |
| 57 | ) |
| 58 | |
| 59 | py_wd_test("worker-entrypoint") |
| 60 | |
| 61 | py_wd_test( |
| 62 | "jspi", |
| 63 | skip_python_flags = ["0.26.0a2"], |
| 64 | ) |
| 65 | |
| 66 | py_wd_test("python-rpc") |
| 67 | |
| 68 | py_wd_test("workflow-entrypoint") |
| 69 | |
| 70 | py_wd_test("vendor_dir_compat_flag") |
| 71 | |
| 72 | py_wd_test("default-class-with-legacy-global-handlers") |
| 73 | |
| 74 | py_wd_test( |
| 75 | "fastapi", |
| 76 | make_snapshot = False, |
| 77 | use_snapshot = "fastapi", |
| 78 | ) |
| 79 | |
| 80 | py_wd_test( |
| 81 | "numpy", |
| 82 | make_snapshot = False, |
| 83 | use_snapshot = "numpy", |
| 84 | ) |
| 85 | |
| 86 | py_wd_test("python-compat-flag") |
| 87 | |
| 88 | py_wd_test("pth-file") |
| 89 | |
| 90 | # Shell-driven test for the python-abort-isolate-on-fatal-error autogate. The Python worker |
| 91 | # triggers a fatal error which (with the autogate enabled) calls abortIsolate(), terminating the |
| 92 | # workerd process. The shell script verifies the expected fatal output and non-zero exit. |
| 93 | sh_test( |
| 94 | name = "python-abort-isolate-on-fatal-test", |
| 95 | size = "enormous", |
| 96 | srcs = ["python-abort-isolate-on-fatal/python-abort-isolate-on-fatal.sh"], |
| 97 | args = [ |
| 98 | "$(location //src/workerd/server:workerd_cross)", |
| 99 | "$(location python-abort-isolate-on-fatal/python-abort-isolate-on-fatal.wd-test)", |
| 100 | "$(location //src/workerd/server/tests/python:pyodide_dev.capnp.bin@rule)", |
| 101 | "../+pyodide+all_pyodide_wheels_20250808", |
| 102 | ], |
| 103 | data = [ |
| 104 | "python-abort-isolate-on-fatal/python-abort-isolate-on-fatal.wd-test", |
| 105 | "python-abort-isolate-on-fatal/worker.py", |
| 106 | "//src/workerd/server:workerd_cross", |
| 107 | "//src/workerd/server/tests/python:pyodide_dev.capnp.bin@rule", |
| 108 | "@all_pyodide_wheels_20250808//:whls", |
| 109 | ], |
| 110 | tags = [ |
| 111 | "no-coverage", |
| 112 | "python", |
| 113 | ], |
| 114 | target_compatible_with = select({ |
| 115 | "@platforms//os:windows": ["@platforms//:incompatible"], |
| 116 | "//conditions:default": [], |
| 117 | }), |
| 118 | ) |