Skip to content

Commit 4987ce3

Browse files
authored
chore: add smoke tests for packages that have entropy patches (#133)
* chore: add smoke tests for packages that have entropy patches * chore: clean up useless tests * chore: remove aiohttp for now * chore: debug * Revert "chore: remove aiohttp for now" This reverts commit 3cd922d. * Revert "chore: debug" This reverts commit 82d8879. * chore: disable entropy test in old compat date
1 parent a697ab6 commit 4987ce3

11 files changed

Lines changed: 119 additions & 1 deletion

File tree

packages/cli/tests/test_in_workerd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def test_in_workerd( # noqa: PLR0913 (too-many-arguments)
6161
# This is reproducible only in the unittest environment, and doesn't happen
6262
# when running the same worker manually.
6363
if (
64-
test_dir.name == "sdk"
64+
test_dir.name in ("sdk", "entropy-patches")
6565
and compat_date < "2025-09-29"
6666
and sys.platform == "linux"
6767
):
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Workerd = import "/workerd/workerd.capnp";
2+
3+
const python :Workerd.Worker = (
4+
modules = [
5+
(name = "worker.py", pythonModule = embed "worker.py"),
6+
%PYTHON_MODULES
7+
],
8+
compatibilityDate = "%COMPAT_DATE",
9+
compatibilityFlags = ["python_workers", "service_binding_extra_handlers", "enable_python_external_sdk", "python_process_pth_files"],
10+
);
11+
12+
const unitTests :Workerd.Config = (
13+
services = [
14+
( name = "entropy-patches",
15+
worker = .python
16+
),
17+
],
18+
);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[project]
2+
name = "test"
3+
version = "0.0.0"
4+
requires-python = ">=3.12"
5+
dependencies = [
6+
"pytest",
7+
"pytest-asyncio<1.2.0",
8+
"numpy",
9+
"pydantic",
10+
"requests",
11+
"urllib3",
12+
"tiktoken",
13+
"cryptography",
14+
"jiter",
15+
"aiohttp",
16+
"langsmith",
17+
"langchain-openai",
18+
]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# ruff: noqa: F401
2+
import aiohttp.http_websocket
3+
4+
5+
def test_import():
6+
# make sure this file is collected by pytest
7+
pass
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# ruff: noqa: F401
2+
import langchain_openai.chat_models.base
3+
import langsmith._internal._constants
4+
5+
6+
def test_import():
7+
# make sure this file is collected by pytest
8+
pass
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# ruff: noqa: F401
2+
import numpy
3+
import numpy.random
4+
import numpy.random.mtrand
5+
6+
7+
def test_import():
8+
# make sure this file is collected by pytest
9+
pass
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# ruff: noqa: F401
2+
import pydantic
3+
import pydantic_core
4+
5+
6+
def test_import():
7+
# make sure this file is collected by pytest
8+
pass
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# ruff: noqa: F401
2+
3+
import cryptography.exceptions
4+
import jiter
5+
import tiktoken._tiktoken
6+
7+
8+
def test_import():
9+
# make sure this file is collected by pytest
10+
pass
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# ruff: noqa: F401
2+
import aiohttp.connector
3+
import requests.adapters
4+
import urllib3.util.ssl_
5+
6+
7+
def test_import():
8+
# make sure this file is collected by pytest
9+
pass
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import asyncio
2+
import os
3+
import sys
4+
5+
import pytest
6+
from pyodide.webloop import WebLoop
7+
from workers import WorkerEntrypoint
8+
9+
10+
async def noop(*args):
11+
pass
12+
13+
14+
# pytest-asyncio relies on these but in Pyodide < 0.29 WebLoop does not implement them
15+
WebLoop.shutdown_asyncgens = noop
16+
WebLoop.shutdown_default_executor = noop
17+
18+
if sys.version_info < (3, 13):
19+
asyncio.runners._cancel_all_tasks = lambda loop: None # type: ignore[attr-defined]
20+
21+
22+
class Default(WorkerEntrypoint):
23+
async def test(self):
24+
os.chdir("/session/metadata/tests")
25+
args = [".", "-vv"]
26+
assert pytest.main(args) == 0

0 commit comments

Comments
 (0)