Skip to content
File

Blob: src/workerd/server/tests/python/BUILD.bazel

3.1 KB
1load("@rules_shell//shell:sh_test.bzl", "sh_test")
2load("//src/workerd/server/tests/python:import_tests.bzl", "gen_rust_import_tests")
3load("//src/workerd/server/tests/python:py_wd_test.bzl", "py_wd_test", "python_test_setup")
4load("//src/workerd/server/tests/python/vendor_pkg_tests:vendor_test.bzl", "vendored_py_wd_test")
5 
6python_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.
13vendored_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 
21py_wd_test("hello")
22 
23py_wd_test("top-level-tests")
24 
25py_wd_test("env-param")
26 
27py_wd_test("asgi")
28 
29py_wd_test("asgi-sse")
30 
31py_wd_test("random")
32 
33py_wd_test("subdirectory")
34 
35py_wd_test(
36 "sdk",
37 compat_date = "2026-01-01",
38)
39 
40gen_rust_import_tests()
41 
42py_wd_test("undefined-handler")
43 
44py_wd_test("vendor_dir")
45 
46py_wd_test("dont-snapshot-pyodide")
47 
48py_wd_test("filter-non-py-files")
49 
50py_wd_test("durable-object")
51 
52py_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 
59py_wd_test("worker-entrypoint")
60 
61py_wd_test(
62 "jspi",
63 skip_python_flags = ["0.26.0a2"],
64)
65 
66py_wd_test("python-rpc")
67 
68py_wd_test("workflow-entrypoint")
69 
70py_wd_test("vendor_dir_compat_flag")
71 
72py_wd_test("default-class-with-legacy-global-handlers")
73 
74py_wd_test(
75 "fastapi",
76 make_snapshot = False,
77 use_snapshot = "fastapi",
78)
79 
80py_wd_test(
81 "numpy",
82 make_snapshot = False,
83 use_snapshot = "numpy",
84)
85 
86py_wd_test("python-compat-flag")
87 
88py_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.
93sh_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)