Tests use CliRunner.isolated_filesystem(), which is deprecated and will be removed in Click 9.0

未關閉 適合新手
#916 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 3 天內回覆

@devpryan7792 已經在處理了。

開始於 2026年10月25日。

  • #917 來自 @devpryan7792 —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
78/100
Issue 類型
重構
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
python
領域
cli, testing

研究方向

先在 tests/test_cli.py 和 tests/test_insert_files.py 中搜尋 isolated_filesystem();issue 列出 22 個呼叫和受影響的測試。閱讀這些測試如何使用相對路徑,然後視需要使用 pytest 的 fixture tmp_path,或切換到該目錄。執行測試套件,並確認它在沒有這些棄用警告的情況下通過。

由索引模型根據 Issue 內容生成。

描述

Running the test suite produces 33 DeprecationWarnings from Click:

DeprecationWarning: 'isolated_filesystem' is deprecated and will be removed in Click 9.0. Use 'tempfile.TemporaryDirectory' or pytest's 'tmp_path' fixture with absolute paths instead.

Once Click 9.0 is released, these tests will fail, since sqlite-utils doesn't pin Click below 9.

Steps to reproduce
git clone https://github.com/simonw/sqlite-utils
cd sqlite-utils
uv run pytest
Expected

Test suite passes with no deprecation warnings from the project's own tests.

Actual

1497 passed, 16 skipped, 33 warnings — all 33 warnings are the isolated_filesystem deprecation.

Affected code

22 with runner.isolated_filesystem(): calls (33 test runs once parametrization is counted):

  • tests/test_cli.py — 19 calls (e.g. test_create_table, test_create_view, test_drop_table, test_enable_wal, test_create_table_strict)
  • tests/test_insert_files.py — 3 calls (test_insert_files, test_insert_files_stdin, test_insert_files_bad_text_encoding_error)

Find them with: grep -n isolated_filesystem tests/*.py

Suggested fix

Replace runner.isolated_filesystem() with pytest's tmp_path fixture (or monkeypatch.chdir(tmp_path) where tests rely on relative paths), as the warning recommends.

Environment
  • macOS (Apple Silicon)
  • Python 3.13.5 (via uv 0.13.5)
  • sqlite-utils 4.2.1, commit [YOUR HASH]
  • pytest 9.1.1
主要語言
Python
星號
2.2k
分支
215
PR 合併指標
30 天內沒有已合併 PR

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

simonw/sqlite-utils 的其他 Issue

查看 simonw/sqlite-utils 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。