Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

CI tests the checkout's module, not the installed wheel

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

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
70/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
github-actions, python
領域
ci-cd, testing-qa

研究方向

先從 tests workflow 及其目前的 install 和 pytest 指令開始,然後從 repository 根目錄重現 import probe。驗證 workflow 測試的是已安裝的 wheel,包括不含 ipython_pygments_lexers.py 的 wheel;完成的標準是,缺少的模組會導致測試執行失敗,而不是針對 checkout 副本通過測試。

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

描述

The tests workflow installs the project with python3 -m pip install "." pytest and then runs python3 -m pytest -v from the repository root. Because python -m puts the current directory first on sys.path, and the project is a single top-level module (ipython_pygments_lexers.py) next to its test file, the tests import ipython_pygments_lexers from the checkout rather than from the installed distribution. We observed this with an import probe in a clean container: in every run, the module was loaded from the working tree.

One consequence is that a packaging mistake in the wheel would not fail CI. To check, we built the wheel from the current main (50791e2) and made a copy of it with ipython_pygments_lexers.py removed. We then ran the tests from the repository root against each wheel (Python 3.12, pytest 9.1.1, pygments 2.21.0):

Command Intact wheel Wheel without the module
python -m pytest (the CI command) 7 passed 7 passed
pytest 7 passed 7 passed
pytest --import-mode=importlib 7 passed ImportError

Switching to the pytest entry point alone is not enough. With the default import mode, pytest inserts the test file's directory (the repository root) into sys.path, which again puts the checkout's module first.

If the intention is to test the installed package, running pytest --import-mode=importlib in the workflow makes the tests import the installed copy. If testing the checkout is intended, and the install is only there for the Pygments entry points, please feel free to close this.

We are studying how Python test suites pick the copy of the code they test, and wanted to share the observation.

主要語言
Python
星號
0
分支
2
PR 合併指標
30 天內沒有已合併 PR

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

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

ipython/ipython-pygments-lexers 的其他 Issue

查看 ipython/ipython-pygments-lexers 的全部 Issue

相似的 Issue

更多 Python Issue

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

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