Skip to content

The agent engineering platform.

cli[minor]: Add disable sockets in unit tests (#19877)

Eugene Yurtsev6f20f140cad9
diff --git a/libs/cli/langchain_cli/integration_template/Makefile b/libs/cli/langchain_cli/integration_template/Makefile
index 2837e81a66..ff29edb3d6 100644
--- a/libs/cli/langchain_cli/integration_template/Makefile
+++ b/libs/cli/langchain_cli/integration_template/Makefile
@@ -7,7 +7,13 @@ all: help
TEST_FILE ?= tests/unit_tests/
integration_test integration_tests: TEST_FILE = tests/integration_tests/
-test tests integration_test integration_tests:
+
+# unit tests are run with the --disable-socket flag to prevent network calls
+test tests:
+ poetry run pytest --disable-socket --allow-unit-socket $(TEST_FILE)
+
+# integration tests are run without the --disable-socket flag to allow network calls
+integration_test integration_tests:
poetry run pytest $(TEST_FILE)
######################
diff --git a/libs/cli/langchain_cli/integration_template/pyproject.toml b/libs/cli/langchain_cli/integration_template/pyproject.toml
index 08a778b2fc..8cb86a745d 100644
--- a/libs/cli/langchain_cli/integration_template/pyproject.toml
+++ b/libs/cli/langchain_cli/integration_template/pyproject.toml
@@ -20,6 +20,7 @@ optional = true
[tool.poetry.group.test.dependencies]
pytest = "^7.4.3"
pytest-asyncio = "^0.23.2"
+pytest-socket = "^0.7.0"
langchain-core = {path = "../../core", develop = true}
[tool.poetry.group.codespell]