core: test runner improvements (#27654)

when running core tests locally this
- prevents langsmith tracing from being enabled by env vars
- prevents network calls
This commit is contained in:
Erick Friis 2024-10-25 15:06:59 -07:00 committed by GitHub
parent ef27ce7a45
commit fbfc6bdade
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 37 additions and 9 deletions

View File

@ -6,14 +6,21 @@ all: help
# Define a variable for the test file path. # Define a variable for the test file path.
TEST_FILE ?= tests/unit_tests/ TEST_FILE ?= tests/unit_tests/
test: test tests:
poetry run pytest $(TEST_FILE) env \
-u LANGCHAIN_TRACING_V2 \
tests: -u LANGCHAIN_API_KEY \
poetry run pytest $(TEST_FILE) -u LANGSMITH_TRACING \
-u LANGCHAIN_PROJECT \
poetry run pytest --disable-socket --allow-unix-socket $(TEST_FILE)
test_watch: test_watch:
poetry run ptw --snapshot-update --now . -- -vv $(TEST_FILE) env \
-u LANGCHAIN_TRACING_V2 \
-u LANGCHAIN_API_KEY \
-u LANGSMITH_TRACING \
-u LANGCHAIN_PROJECT \
poetry run ptw --snapshot-update --now . --disable-socket --allow-unix-socket -- -vv $(TEST_FILE)
test_profile: test_profile:
poetry run pytest -vv tests/unit_tests/ --profile-svg poetry run pytest -vv tests/unit_tests/ --profile-svg
@ -22,7 +29,7 @@ check_imports: $(shell find langchain_core -name '*.py')
poetry run python ./scripts/check_imports.py $^ poetry run python ./scripts/check_imports.py $^
extended_tests: extended_tests:
poetry run pytest --only-extended $(TEST_FILE) poetry run pytest --only-extended --disable-socket --allow-unix-socket $(TEST_FILE)
###################### ######################

18
libs/core/poetry.lock generated
View File

@ -1,4 +1,4 @@
# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. # This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand.
[[package]] [[package]]
name = "annotated-types" name = "annotated-types"
@ -2035,6 +2035,20 @@ pytest = ">=6.2.5"
[package.extras] [package.extras]
dev = ["pre-commit", "pytest-asyncio", "tox"] dev = ["pre-commit", "pytest-asyncio", "tox"]
[[package]]
name = "pytest-socket"
version = "0.7.0"
description = "Pytest Plugin to disable socket calls during tests"
optional = false
python-versions = ">=3.8,<4.0"
files = [
{file = "pytest_socket-0.7.0-py3-none-any.whl", hash = "sha256:7e0f4642177d55d317bbd58fc68c6bd9048d6eadb2d46a89307fa9221336ce45"},
{file = "pytest_socket-0.7.0.tar.gz", hash = "sha256:71ab048cbbcb085c15a4423b73b619a8b35d6a307f46f78ea46be51b1b7e11b3"},
]
[package.dependencies]
pytest = ">=6.2.5"
[[package]] [[package]]
name = "pytest-watcher" name = "pytest-watcher"
version = "0.3.5" version = "0.3.5"
@ -2962,4 +2976,4 @@ type = ["pytest-mypy"]
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = ">=3.9,<4.0" python-versions = ">=3.9,<4.0"
content-hash = "06bd735e73dd0eff94b3fbf2c429280a5908e01c9b7f0273865be39c02458874" content-hash = "3c680384ebb62b873c70201979927665c8fcce32dbf1df7457d12e83fba15ac2"

View File

@ -84,17 +84,20 @@ classmethod-decorators = [ "classmethod", "langchain_core.utils.pydantic.pre_ini
[tool.poetry.group.lint.dependencies] [tool.poetry.group.lint.dependencies]
ruff = "^0.5" ruff = "^0.5"
[tool.poetry.group.typing.dependencies] [tool.poetry.group.typing.dependencies]
mypy = ">=1.10,<1.11" mypy = ">=1.10,<1.11"
types-pyyaml = "^6.0.12.2" types-pyyaml = "^6.0.12.2"
types-requests = "^2.28.11.5" types-requests = "^2.28.11.5"
types-jinja2 = "^2.11.9" types-jinja2 = "^2.11.9"
[tool.poetry.group.dev.dependencies] [tool.poetry.group.dev.dependencies]
jupyter = "^1.0.0" jupyter = "^1.0.0"
setuptools = "^67.6.1" setuptools = "^67.6.1"
grandalf = "^0.8" grandalf = "^0.8"
[tool.poetry.group.test.dependencies] [tool.poetry.group.test.dependencies]
pytest = "^8" pytest = "^8"
freezegun = "^1.2.2" freezegun = "^1.2.2"
@ -104,6 +107,7 @@ pytest-watcher = "^0.3.4"
pytest-asyncio = "^0.21.1" pytest-asyncio = "^0.21.1"
grandalf = "^0.8" grandalf = "^0.8"
responses = "^0.25.0" responses = "^0.25.0"
pytest-socket = "^0.7.0"
[[tool.poetry.group.test.dependencies.numpy]] [[tool.poetry.group.test.dependencies.numpy]]
version = "^1.24.0" version = "^1.24.0"
python = "<3.12" python = "<3.12"
@ -112,12 +116,15 @@ python = "<3.12"
version = "^1.26.0" version = "^1.26.0"
python = ">=3.12" python = ">=3.12"
[tool.poetry.group.test_integration.dependencies] [tool.poetry.group.test_integration.dependencies]
[tool.poetry.group.typing.dependencies.langchain-text-splitters] [tool.poetry.group.typing.dependencies.langchain-text-splitters]
path = "../text-splitters" path = "../text-splitters"
develop = true develop = true
[tool.poetry.group.test.dependencies.langchain-standard-tests] [tool.poetry.group.test.dependencies.langchain-standard-tests]
path = "../standard-tests" path = "../standard-tests"
develop = true develop = true