问题:本机 `%TEMP%\pytest-of-Windows` 被权限更高的会话建过,当前用户无权写入, 于是所有用 `tmp_path` 的用例在 setup 阶段批量 ERROR(WinError 5)——实测 33 个, 散布在 offsite 附件预览、通知发送、promotion、worker 等处。这类噪声会让 "到底哪里坏了"完全看不出来(同事这批新用例首次把它暴露出来)。 修法:在 tests/conftest.py 覆盖 `tmp_path`,把根目录改到仓库内 `.workdir/pytest-tmp` (已在 .gitignore)。语义不变——每个用例仍拿到一个**新建的空目录**(残留目录会污染断言)。 只覆盖 `tmp_path` 而不动 `tmp_path_factory`:后者是 pytest 私有构造,参数随版本变化 (实测直接实例化 `TempPathFactory(...)` 会 TypeError),而本仓库用例只用 `tmp_path`。 同时把 pyproject.toml 里那条 `basetemp = ...` 删掉:pytest **只在命令行认 basetemp**, 写在 ini 里会被静默忽略(实测无效),留着会让人误以为已配好。改为注释指向 conftest。 效果:不带任何参数 `pytest -q` 从「3 failed + 33 errors」变为「3 failed,0 error」。
74 lines
1.9 KiB
TOML
74 lines
1.9 KiB
TOML
[build-system]
|
||
requires = ["setuptools>=75"]
|
||
build-backend = "setuptools.build_meta"
|
||
|
||
[project]
|
||
name = "jr-agent-platform"
|
||
version = "0.1.0"
|
||
description = "金融系统 Agent 通用底座"
|
||
requires-python = ">=3.13,<3.14"
|
||
dependencies = [
|
||
"fastapi>=0.115,<1",
|
||
"uvicorn[standard]>=0.34,<1",
|
||
"pydantic>=2.10,<3",
|
||
"pydantic-settings>=2.7,<3",
|
||
"python-dotenv>=1.0,<2",
|
||
"greenlet>=3.1,<4",
|
||
"sqlalchemy>=2.0,<3",
|
||
"alembic>=1.14,<2",
|
||
"asyncmy>=0.2,<1",
|
||
"pymysql>=1.1,<2",
|
||
"redis>=5.2,<6",
|
||
"neo4j>=5.28,<6",
|
||
"pymilvus>=2.5,<3",
|
||
"PyJWT>=2.10,<3",
|
||
"cryptography>=44,<51",
|
||
"httpx>=0.28,<1",
|
||
"tzdata>=2025.1,<2027",
|
||
"alibabacloud_docmind_api20220711==1.4.14",
|
||
"alibabacloud_tea_openapi>=0.4.3,<1",
|
||
"alibabacloud_tea_util>=0.3.13,<1",
|
||
"alibabacloud_credentials>=1.0.2,<2",
|
||
"python-pptx>=1.0,<2",
|
||
"openpyxl>=3.1,<4",
|
||
"Pillow>=10,<12",
|
||
"matplotlib>=3.9,<4",
|
||
"python-multipart>=0.0.20,<1",
|
||
]
|
||
|
||
[project.optional-dependencies]
|
||
dev = [
|
||
"pytest>=8.3,<9",
|
||
"pytest-asyncio>=0.25,<1",
|
||
"ruff>=0.9,<1",
|
||
"mypy>=1.14,<2",
|
||
]
|
||
|
||
[tool.setuptools.packages.find]
|
||
include = ["app*"]
|
||
|
||
[tool.pytest.ini_options]
|
||
testpaths = ["tests"]
|
||
asyncio_mode = "auto"
|
||
asyncio_default_fixture_loop_scope = "function"
|
||
markers = ["integration: requires local database services"]
|
||
# 临时目录的落点由 `tests/conftest.py` 覆盖 `tmp_path` 决定(落在仓库内 `.workdir/pytest-tmp`)。
|
||
# 这里**不**写 `basetemp`:pytest 只在命令行认它,写在 ini 里会被静默忽略(实测无效),
|
||
# 留着会让人误以为已经配好了。系统临时目录权限坏掉的原因与修法见 conftest 的说明。
|
||
|
||
[tool.ruff]
|
||
line-length = 100
|
||
target-version = "py313"
|
||
|
||
[tool.ruff.lint]
|
||
select = ["E", "F", "I", "B", "UP"]
|
||
|
||
[tool.ruff.lint.per-file-ignores]
|
||
"alembic/versions/*.py" = ["E501"]
|
||
"tools/*.py" = ["E501", "I001", "B007"]
|
||
|
||
[tool.mypy]
|
||
python_version = "3.13"
|
||
strict = true
|
||
packages = ["app"]
|