Skip to main content

tuner-testkit

发行名 tuner-testkit,导入名 tuner_testkit。给被测系统(SUT)测试仓提供公共运行库与 CLI(db / API / Web UI / 录制 / mock),以及 Cursor/git DNA(rules、skills、hooks)。

业务资产(page/api objects、action words、features)留在各项目仓packages/tests/,不进本包。平台发新版本后,下游用 uv 按需升级,不必再整树拷贝运行库。


标准作业流程

1. 工具域:只装核心 kit(能 tuner-init 即可)

uv tool install 和业务仓 .venv 是两套环境。下游在 tool 域只装默认 wheel,用来拿 tuner-init / tuner-dna不要在 tool 域打开 [db] / [api] 等 extra。

uv tool install tuner-testkit

入口命令是 tuner-inittuner-dna 等(tuner-*),没有 tuner-testkit 这个 script。tuner-dump-ddltuner-recorder 等依赖 extra 的 CLI,请在业务仓用 uv run … 跑,走该仓 .venv

2. 初始化测试仓

tuner-init scaffold ../my-sut-tests
cd ../my-sut-tests
uv sync

scaffold 会铺六层目录、写入依赖 tuner-testkit[db,api]pyproject.toml,并执行一次 tuner-dna sync(把 .cursor/docs/spec/tools/git-hooks/ 放进项目树)。可在任意目录运行,不必先有测试仓。不要用 tuner-testkit init repo

uv syncdb / api 装进业务仓 .venv,不是 tool 域。已有项目仓则在该仓根目录:

uv add "tuner-testkit[db,api]>=4.0.0"
uv sync

Web UI / 合录等按需再加 extra:

uv add "tuner-testkit[web-ui]"
uv add "tuner-testkit[recorder]"

测 kit 全能力(平台狗食仓等)一次打开全部能力 extra:

uv add "tuner-testkit[all]"
uv sync

3. 开始写业务

项目仓里写,不要改 site-packages 里的 kit:

你写什么 放哪里
页面 / 接口资产 packages/page_objects/packages/api_objects/
业务动作 packages/action_words/
BDD / pytest tests/features/tests/pytest/
知识(DDL、用例) assets/
本仓私有工具 apps/python -m apps.<name>

代码里 from tuner_testkit.db import … / from tuner_testkit.page_test import …。密钥只放本机 config/env_local.py 或环境变量(TUNER_ENVTUNER_DB_<ALIAS>_*),不要提交

录制产物同样写到项目仓 packages/,不会写进 venv。

4. 获取 PyPI 上的更新

平台发新版本后,下游从 PyPI:tuner-testkit 取 wheel,不要再拷本仓源码。tool 域和业务仓 .venv 是两份安装,两边都要升,再铺 DNA。

先看当前装的是哪一版、PyPI 最新是哪一版:

uv tool list                          # tool 域里的 tuner-testkit
cd ../my-sut-tests
uv pip show tuner-testkit             # 业务仓 .venv

发行说明见 docs/changelog/FRAMEWORK.md 与该版本的 docs/changelog/TEMPLATE-*.md

① tool 域(只升核心 CLI)

uv tool upgrade tuner-testkit

升的是 tuner-init / tuner-dna 所在环境。这里仍然不要[db] / [api]。尚未 uv tool install 过则先执行第 1 节。

② 业务仓 .venv(升运行库 + extras)

项目仓根目录改依赖并同步 lock。保留你原来打开的 extra(普通仓 [db,api],狗食/全能力仓 [all]):

# 钉到某一发行版(推荐,和团队 lock 一致)
uv add "tuner-testkit[db,api]==4.2.0"

# 或只抬下限,让解析器选允许范围内的最新
# uv add "tuner-testkit[db,api]>=4.2.0"

uv sync

已经写过 >=4.0.0、只想把 lock 里的 kit 升到 PyPI 最新:

uv lock --upgrade-package tuner-testkit
uv sync

只改 pyproject.toml 里的版本再 uv lock / uv sync 也可以。一个 wheel 不能「只升 web-ui、钉死旧 db」。

③ 同步 DNA 并提交

uv add / uv sync 只更新 site-packages 里的运行库。Cursor 读的是项目树里的 .cursor/docs/spec/tools/git-hooks/,必须再铺一层:

tuner-dna sync
tuner-dna check
git add -A && git commit

tuner-dna check 核对项目树 DNA 是否与当前 PATH 上那份 kit 一致。建议先 uv tool upgrade,再 sync,避免 CLI 还是旧包、.venv 已是新包。

新仓第一次仍用第 2 节的 tuner-init scaffold(会写依赖并做一次 tuner-dna sync),不是每次发版都重新 scaffold。

[phone-ui] 为预留空 extra,4.0 未实现。


extras

extra 内容
(默认 wheel) config / loggingtuner-inittuner-dna(tool 域只装这个)
[db] MySQL / SQL Server / PostgreSQL(装在业务仓 .venv
[api] api_test(HTTP 客户端)
[web-ui] page_test + Playwright
[phone-ui] 预留,无实现
[recorder] 合录 / 仅 UI / mitmproxy 代理
[mock] 按冻结的 api_objects 回放
[excel] / [fake] 表格 / 假数据
[bdd] / [test] behave / pytest
[all] 元 extra:上述能力 extra 的并集(不含 [dev]
[dev] tuner-testkit[all],给本仓 editable 开发

CLI 与 python -m tuner_testkit.… 等价,例如 tuner-recordertuner-page-recordertuner-api-recordertuner-mock-server。依赖 extra 的命令在业务仓用 uv run tuner-dump-ddl / uv run tuner-recorder


安全

不得把 token、cookie、Authorization、密码、session 写入仓库(含 capture 与 api_objects)。凭证只允许运行时注入。


本仓库(平台源码)

克隆后在仓库根目录开发 kit 本身:

uv venv
uv sync --extra all

uv sync --extra dev--extra all 等价(dev 只是引用 [all])。

4.2.0 发行说明见 docs/changelog/TEMPLATE-4.2.0.md;3.x → 4.x 迁移见 TEMPLATE-4.0.0.md。平台能力地图见 INDEX.md

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tuner_testkit-4.2.0.tar.gz (283.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tuner_testkit-4.2.0-py3-none-any.whl (365.5 kB view details)

Uploaded Python 3

File details

Details for the file tuner_testkit-4.2.0.tar.gz.

File metadata

  • Download URL: tuner_testkit-4.2.0.tar.gz
  • Upload date:
  • Size: 283.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tuner_testkit-4.2.0.tar.gz
Algorithm Hash digest
SHA256 bbae370fd9f7c0b8ed48a3f1af674a6a6ccf3ae29446bf088aab9a02e682be21
MD5 7e2309d65436e694502737b80101654c
BLAKE2b-256 d8e1a077a16e878f4506fb8f7a519aaf90f326c381b5965c4a0d305dedf9b1e3

See more details on using hashes here.

File details

Details for the file tuner_testkit-4.2.0-py3-none-any.whl.

File metadata

  • Download URL: tuner_testkit-4.2.0-py3-none-any.whl
  • Upload date:
  • Size: 365.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tuner_testkit-4.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d99e96af00748111775d6ae530c92517c435ec3d335582e7b2992a211be0fff
MD5 c79e33cfd0c40652a61872ce3bf3a6cc
BLAKE2b-256 0ea09f2d20d1b59401b39a8512a0133c01fc772fb96ee079a2ea235a6db71f2b

See more details on using hashes here.

Release history Release notifications | RSS feed

4.3.0

2 files

This release

4.2.0 This release

2 files

4.1.0

2 files

4.0.2

2 files

4.0.1

2 files

4.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page