CI tests the checkout's module, not the installed wheel
还没有人认领这个 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,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ipython/ipython-pygments-lexers 的其他 Issue
-
failure on shell commands after `%%time`可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 68/100
查看 ipython/ipython-pygments-lexers 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
Juniper/ansible-junos-stdlib#904 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
pollen-robotics/reachy_mini#1457 ·
维护者通常 1 天内回复
-
area:runtime good first issue
难度 2/5 1-3 小时 新手友好度 72/100
WATonomous/wato_f1tenth#39 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
FireDynamics/fdsreader#123 ·
-
难度 1/5 1 小时以内 新手友好度 85/100