Files
Chan/web/tests/test_cn_stock_data_fetch.py
T
jackyu66gitandCursor 7f393b93ed refactor: 精简仓库为 chanlun 核心与 web 分析,移除威科夫与遗留模块
删除根目录旧 Chan 模块、策略、配置、文档及 wyckoff 相关代码;更新缠论 pipeline 与笔中枢计算;补充 research 研究与 web 测试。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-27 01:05:12 +08:00

33 lines
1007 B
Python

from __future__ import annotations
import sys
from pathlib import Path
import pytest
WEB_ROOT = Path(__file__).resolve().parents[1]
if str(WEB_ROOT) not in sys.path:
sys.path.insert(0, str(WEB_ROOT))
from cn_stock_data import ChinaStockData
@pytest.mark.network
def test_cn_stock_data_fetch():
"""简单的联通性测试,确认能否通过 akshare 拉取A股K线数据。"""
data_client = ChinaStockData()
try:
df = data_client.get_kl_data(symbol="600519", timeframe="1d", limit=20)
except Exception as exc: # pragma: no cover - 旨在提示网络/依赖问题
pytest.skip(f"无法调用数据接口,可能是网络或依赖问题:{exc}")
if df is None or df.empty:
pytest.skip("未获取到任何数据,可能是网络异常或接口限制。")
expected_cols = {"date", "open", "high", "low", "close", "volume"}
missing_cols = expected_cols - set(df.columns)
assert not missing_cols, f"返回数据缺少列: {missing_cols}"