Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/tests/test_in_workerd.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_in_workerd( # noqa: PLR0913 (too-many-arguments)
# This is reproducible only in the unittest environment, and doesn't happen
# when running the same worker manually.
if (
test_dir.name == "sdk"
test_dir.name in ("sdk", "entropy-patches")
and compat_date < "2025-09-29"
and sys.platform == "linux"
):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Workerd = import "/workerd/workerd.capnp";

const python :Workerd.Worker = (
modules = [
(name = "worker.py", pythonModule = embed "worker.py"),
%PYTHON_MODULES
],
compatibilityDate = "%COMPAT_DATE",
compatibilityFlags = ["python_workers", "service_binding_extra_handlers", "enable_python_external_sdk", "python_process_pth_files"],
);

const unitTests :Workerd.Config = (
services = [
( name = "entropy-patches",
worker = .python
),
],
);
18 changes: 18 additions & 0 deletions packages/cli/tests/workerd-test/entropy-patches/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[project]
name = "test"
version = "0.0.0"
requires-python = ">=3.12"
dependencies = [
"pytest",
"pytest-asyncio<1.2.0",
"numpy",
"pydantic",
"requests",
"urllib3",
"tiktoken",
"cryptography",
"jiter",
"aiohttp",
"langsmith",
"langchain-openai",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# ruff: noqa: F401
import aiohttp.http_websocket


def test_import():
# make sure this file is collected by pytest
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ruff: noqa: F401
import langchain_openai.chat_models.base
import langsmith._internal._constants


def test_import():
# make sure this file is collected by pytest
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ruff: noqa: F401
import numpy
import numpy.random
import numpy.random.mtrand


def test_import():
# make sure this file is collected by pytest
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ruff: noqa: F401
import pydantic
import pydantic_core


def test_import():
# make sure this file is collected by pytest
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ruff: noqa: F401

import cryptography.exceptions
import jiter
import tiktoken._tiktoken


def test_import():
# make sure this file is collected by pytest
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ruff: noqa: F401
import aiohttp.connector
import requests.adapters
import urllib3.util.ssl_


def test_import():
# make sure this file is collected by pytest
pass
26 changes: 26 additions & 0 deletions packages/cli/tests/workerd-test/entropy-patches/worker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import asyncio
import os
import sys

import pytest
from pyodide.webloop import WebLoop
from workers import WorkerEntrypoint


async def noop(*args):
pass


# pytest-asyncio relies on these but in Pyodide < 0.29 WebLoop does not implement them
WebLoop.shutdown_asyncgens = noop
WebLoop.shutdown_default_executor = noop

if sys.version_info < (3, 13):
asyncio.runners._cancel_all_tasks = lambda loop: None # type: ignore[attr-defined]


class Default(WorkerEntrypoint):
async def test(self):
os.chdir("/session/metadata/tests")
args = [".", "-vv"]
assert pytest.main(args) == 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "test-worker",
"compatibility_date": "%COMPAT_DATE",
"compatibility_flags": ["python_workers"]
}
Loading