The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
Block sockets for unit-tests (#4803)
Eugene Yurtsevc3b6129beb6a
diff --git a/Makefile b/Makefileindex 382591e68f..8793a47d9a 100644--- a/Makefile+++ b/Makefile@@ -35,13 +35,13 @@ lint lint_diff:TEST_FILE ?= tests/unit_tests/test:- poetry run pytest $(TEST_FILE)+ poetry run pytest --disable-socket --allow-unix-socket $(TEST_FILE)-tests:- poetry run pytest $(TEST_FILE)+tests:+ poetry run pytest --disable-socket --allow-unix-socket $(TEST_FILE)extended_tests:- poetry run pytest --only-extended tests/unit_tests+ poetry run pytest --disable-socket --allow-unix-socket --only-extended tests/unit_teststest_watch:poetry run ptw --now . -- tests/unit_testsdiff --git a/poetry.lock b/poetry.lockindex 72a7c08688..405486c0b2 100644--- a/poetry.lock+++ b/poetry.lock@@ -6982,6 +6982,21 @@ pytest = ">=5.0"[package.extras]dev = ["pre-commit", "pytest-asyncio", "tox"]+[[package]]+name = "pytest-socket"+version = "0.6.0"+description = "Pytest Plugin to disable socket calls during tests"+category = "dev"+optional = false+python-versions = ">=3.7,<4.0"+files = [+ {file = "pytest_socket-0.6.0-py3-none-any.whl", hash = "sha256:cca72f134ff01e0023c402e78d31b32e68da3efdf3493bf7788f8eba86a6824c"},+ {file = "pytest_socket-0.6.0.tar.gz", hash = "sha256:363c1d67228315d4fc7912f1aabfd570de29d0e3db6217d61db5728adacd7138"},+]++[package.dependencies]+pytest = ">=3.6.3"+[[package]]name = "pytest-vcr"version = "1.0.2"@@ -10257,4 +10272,4 @@ qdrant = ["qdrant-client"][metadata]lock-version = "2.0"python-versions = ">=3.8.1,<4.0"-content-hash = "811c25dc41049bffd84ddd350dbbbca8736737182dc8582dfbe05ce517122739"+content-hash = "a41fec88e32b74b859208dd79de58c096466aeda631c17048e6b903100f7ac70"diff --git a/pyproject.toml b/pyproject.tomlindex f77fd74795..9be1a87f5e 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -114,6 +114,7 @@ responses = "^0.22.0"pytest-asyncio = "^0.20.3"lark = "^1.1.5"pytest-mock = "^3.10.0"+pytest-socket = "^0.6.0"[tool.poetry.group.test_integration]optional = truediff --git a/tests/unit_tests/test_pytest_config.py b/tests/unit_tests/test_pytest_config.pynew file mode 100644index 0000000000..fe588e60d1--- /dev/null+++ b/tests/unit_tests/test_pytest_config.py@@ -0,0 +1,9 @@+import pytest+import pytest_socket+import requests+++def test_socket_disabled() -> None:+ """This test should fail."""+ with pytest.raises(pytest_socket.SocketBlockedError):+ requests.get("https://www.example.com")