mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-17 21:25:46 +02:00
Make it possible to run test command without docker installed (#4948)
This commit is contained in:
+14
-7
@@ -56,15 +56,22 @@ stop-dev-server:
|
||||
fi
|
||||
|
||||
TEST ?= .
|
||||
NO_DOCKER ?= $(sh command -v docker >/dev/null 2>&1 && echo "false" || echo "true")
|
||||
|
||||
test:
|
||||
make start-postgres &&\
|
||||
make start-dev-server &&\
|
||||
uv run pytest $(TEST); \
|
||||
EXIT_CODE=$$?; \
|
||||
make stop-postgres; \
|
||||
make stop-dev-server; \
|
||||
exit $$EXIT_CODE
|
||||
if [ "$(NO_DOCKER)" = "false" ]; then \
|
||||
make start-postgres &&\
|
||||
make start-dev-server &&\
|
||||
uv run pytest $(TEST); \
|
||||
EXIT_CODE=$$?; \
|
||||
make stop-postgres; \
|
||||
make stop-dev-server; \
|
||||
exit $$EXIT_CODE; \
|
||||
else \
|
||||
NO_DOCKER=true uv run pytest $(TEST) ; \
|
||||
EXIT_CODE=$$?; \
|
||||
exit $$EXIT_CODE; \
|
||||
fi
|
||||
|
||||
test_parallel:
|
||||
make start-postgres &&\
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
from collections.abc import AsyncIterator, Iterator
|
||||
from uuid import UUID
|
||||
|
||||
@@ -31,6 +32,8 @@ from tests.conftest_store import (
|
||||
_store_postgres_pool,
|
||||
)
|
||||
|
||||
NO_DOCKER = os.getenv("NO_DOCKER", "false") == "true"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def anyio_backend():
|
||||
@@ -62,7 +65,9 @@ def cache(request: pytest.FixtureRequest) -> Iterator[BaseCache]:
|
||||
|
||||
@pytest.fixture(
|
||||
scope="function",
|
||||
params=["in_memory", "postgres", "postgres_pipe", "postgres_pool"],
|
||||
params=["in_memory"]
|
||||
if NO_DOCKER
|
||||
else ["in_memory", "postgres", "postgres_pipe", "postgres_pool"],
|
||||
)
|
||||
def sync_store(request: pytest.FixtureRequest) -> Iterator[BaseStore]:
|
||||
store_name = request.param
|
||||
@@ -86,7 +91,9 @@ def sync_store(request: pytest.FixtureRequest) -> Iterator[BaseStore]:
|
||||
|
||||
@pytest.fixture(
|
||||
scope="function",
|
||||
params=["in_memory", "postgres_aio", "postgres_aio_pipe", "postgres_aio_pool"],
|
||||
params=["in_memory"]
|
||||
if NO_DOCKER
|
||||
else ["in_memory", "postgres_aio", "postgres_aio_pipe", "postgres_aio_pool"],
|
||||
)
|
||||
async def async_store(request: pytest.FixtureRequest) -> AsyncIterator[BaseStore]:
|
||||
store_name = request.param
|
||||
@@ -114,6 +121,12 @@ async def async_store(request: pytest.FixtureRequest) -> AsyncIterator[BaseStore
|
||||
"memory",
|
||||
"sqlite",
|
||||
"sqlite_aes",
|
||||
]
|
||||
if NO_DOCKER
|
||||
else [
|
||||
"memory",
|
||||
"sqlite",
|
||||
"sqlite_aes",
|
||||
"postgres",
|
||||
"postgres_pipe",
|
||||
"postgres_pool",
|
||||
@@ -150,6 +163,11 @@ def sync_checkpointer(
|
||||
params=[
|
||||
"memory",
|
||||
"sqlite_aio",
|
||||
]
|
||||
if NO_DOCKER
|
||||
else [
|
||||
"memory",
|
||||
"sqlite_aio",
|
||||
"postgres_aio",
|
||||
"postgres_aio_pipe",
|
||||
"postgres_aio_pool",
|
||||
|
||||
@@ -17,8 +17,15 @@ from langgraph.pregel import Pregel
|
||||
from langgraph.pregel.remote import RemoteGraph
|
||||
from langgraph.pregel.types import StateSnapshot
|
||||
from langgraph.types import Interrupt
|
||||
from tests.conftest import NO_DOCKER
|
||||
from tests.example_app.example_graph import app
|
||||
|
||||
if NO_DOCKER:
|
||||
pytest.skip(
|
||||
"Skipping tests that require Docker. Unset NO_DOCKER to run them.",
|
||||
allow_module_level=True,
|
||||
)
|
||||
|
||||
pytestmark = pytest.mark.anyio
|
||||
|
||||
NEEDS_CONTEXTVARS = pytest.mark.skipif(
|
||||
|
||||
Reference in New Issue
Block a user