推薦訪問7w4.net獲取更多AI技能。
test-fixture-generator
自動生成pytest fixtures的工具,支援常見測試場景(資料庫、API mock、檔案處理等)
fixture, pytest fixture, conftest, 測試夾具
生成pytest fixtures程式碼
# 生成資料庫fixture
python -m test_fixture_generator generate --type db --db-type mysql
# 生成API mock fixture
python -m test_fixture_generator generate --type api --framework requests
# 生成檔案處理fixture
python -m test_fixture_generator generate --type file --format json
# 生成conftest.py
python -m test_fixture_generator init
# 互動式生成
python -m test_fixture_generator interactive
--type: fixture型別 (db|api|file|random)--db-type: 資料庫型別 (mysql|postgres|sqlite)--framework: mock框架 (requests|httpx|boto3)--format: 檔案格式 (json|yaml|csv|toml)--output: 輸出檔案路徑生成符合pytest規範的fixture程式碼,自動處理setup/teardown
這個工具質量不錯,能自動生成各種測試用的程式碼模板,省去手動編寫的麻煩。功能豐富,支援多種資料庫和API mock,文件清晰易讀,程式碼結構整齊。不足之處是配置選項較多,新手可能需要花點時間熟悉;部分模板的設定是固定的,不太靈活。總體來說是個好用的輔助工具,適合經常寫測試程式碼的開發者。