用途:在 contentstack-python SDK 中新增或修改测试、排查测试失败、理解凭据加载方式,以及为新功能补充测试覆盖。
主要能力与用法:测试位于 tests/ 目录,常用命令包括全量测试 pytest tests/、单文件 pytest tests/test_stack.py,以及覆盖率 pytest --cov=contentstack tests/。凭据来自根目录 config.py,包含 HOST、APIKEY、DELIVERYTOKEN、ENVIRONMENT,以及可选的 PREVIEW_TOKEN 和特定套件所需的内容 UID;应使用本地 config.py 或脱敏后的值,禁止提交真实密钥。
测试约定:测试类继承 unittest.TestCase,tests/pytest.ini 定义警告过滤规则。按模块划分:栈与区域见 tests/test_stack.py;查询见 tests/test_query.py、tests/test_basequery.py;条目与资源见 tests/test_entry.py、tests/test_assets.py;分类法、全局字段与实时预览见 tests/test_taxonomies.py、tests/test_global_fields.py、tests/test_live_preview.py;早期访问见 tests/test_early_find.py、tests/test_early_fetch.py。
卫生要求:不得提交无原因的 pytest.mark.skip;除非 CI 环境确实不可用,否则避免使用 @unittest.skip;不得提交真实 API key、delivery token 或 preview token。
限制:资料未提供具体版本、依赖安装命令或 CI 配置细节。