chore: 搭建项目骨架
- pyproject:hatchling + src 布局,核心依赖 psycopg/pydantic/pyyaml/cel-python - FastAPI 归入 [api] 可选依赖,开发依赖走 PEP 735 dependency-groups - 建立分层目录:ontology/compiler/storage/repository/graph/timeseries/expr/rules/api - errors.py 统一异常基类;py.typed 标记类型完整 - ruff(100) + pytest 配置;冒烟测试校验核心包不引入 fastapi/uvicorn
This commit is contained in:
1 parent
ecd5925b2c
commit
ace505cc6b
16 files changed
+1544
-11
No files matched your search
@@ -0,0 +1,38 @@
|
||||
"""骨架冒烟测试:包能导入,且核心包不拉起 web 依赖(AGENTS.md §5 硬规则)。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def test_package_imports() -> None:
|
||||
import adapter_python_pg
|
||||
|
||||
assert adapter_python_pg.__version__ == "0.1.0"
|
||||
|
||||
|
||||
def test_core_import_does_not_pull_fastapi() -> None:
|
||||
"""在干净的解释器里 import 核心包,sys.modules 不应出现 fastapi / uvicorn。"""
|
||||
code = (
|
||||
"import sys, adapter_python_pg;"
|
||||
"assert 'fastapi' not in sys.modules, 'core imported fastapi';"
|
||||
"assert 'uvicorn' not in sys.modules, 'core imported uvicorn';"
|
||||
"print('ok')"
|
||||
)
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-c", code],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
assert result.returncode == 0, result.stderr
|
||||
assert result.stdout.strip() == "ok"
|
||||
|
||||
|
||||
def test_unknown_attribute_raises() -> None:
|
||||
import pytest
|
||||
|
||||
import adapter_python_pg
|
||||
|
||||
with pytest.raises(AttributeError):
|
||||
_ = adapter_python_pg.nonexistent_attribute
|
||||
Reference in new issue
Block a user