test_lazy_choices_help fails on Python 3.14
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 52/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- python
- 領域
- cli, testing-qa
調査の方向性
tests/test_cli_utils.py::test_lazy_choices_help から始め、Python 3.14 と記載されている uv コマンドを使って失敗を再現します。ArgumentParser と LazyChoices の初期化を追跡して getter が早い段階で呼び出される理由を突き止め、その後、期待される lazy な動作を変更せずにテストを成功させます。
索引モデルが issue の本文から書いたものです。
説明
Checklist
- I've searched for similar issues.
- I'm using the latest version of HTTPie (from git HEAD)
Minimal reproduction code and steps
This is with Python 3.14.0b3 and b4 alike.
uv venv --python=python3.14 venv
. venv/bin/activate
uv pip install '.[dev]'
uv pip install -U httpbin flask werkzeug # to support Python 3.14
python -m pytest --verbose -k test_lazy_choices_help
Current result
============================= test session starts ==============================
platform linux -- Python 3.14.0b3, pytest-8.4.1, pluggy-1.6.0 -- .../httpie/venv/bin/python
cachedir: .pytest_cache
rootdir: .../httpie
configfile: pytest.ini
plugins: mock-3.14.1, httpbin-2.1.0, cov-6.2.1
collecting ... collected 1028 items / 1027 deselected / 1 selected
tests/test_cli_utils.py::test_lazy_choices_help FAILED [100%]
=================================== FAILURES ===================================
____________________________ test_lazy_choices_help ____________________________
self = <Mock name='mock.getter' id='140611738470112'>
def assert_not_called(self):
"""assert that the mock was never called.
"""
if self.call_count != 0:
msg = ("Expected '%s' to not have been called. Called %s times.%s"
% (self._mock_name or 'mock',
self.call_count,
self._calls_repr()))
> raise AssertionError(msg)
E AssertionError: Expected 'getter' to not have been called. Called 1 times.
E Calls: [call()].
/usr/lib64/python3.14/unittest/mock.py:946: AssertionError
During handling of the above exception, another exception occurred:
def test_lazy_choices_help():
mock = Mock()
getter = mock.getter
getter.return_value = ['a', 'b', 'c']
help_formatter = mock.help_formatter
help_formatter.return_value = '<my help>'
parser = ArgumentParser()
parser.register('action', 'lazy_choices', LazyChoices)
parser.add_argument(
'--lazy-option',
default='a',
metavar='SYMBOL',
action='lazy_choices',
getter=getter,
help_formatter=help_formatter,
cache=False # for test purposes
)
# Parser initialization doesn't call it.
> getter.assert_not_called()
E AssertionError: Expected 'getter' to not have been called. Called 1 times.
E Calls: [call()].
tests/test_cli_utils.py:73: AssertionError
=============================== warnings summary ===============================
httpie/cli/definition.py:526
.../httpie/httpie/cli/definition.py:526: PendingDeprecationWarning: FileType is deprecated. Simply open files after parsing arguments.
type=FileType('a+b'),
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/test_cli_utils.py::test_lazy_choices_help - AssertionError: Expe...
================ 1 failed, 1027 deselected, 1 warning in 0.20s =================
Expected result
Tests pass.
- 主要言語
- Python
- スター
- 38.6k
- フォーク
- 4k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
httpie/cli のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
new
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
bug new
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
PedestrianDynamics/pyFDS-Evac#343 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
theskumar/python-dotenv#708 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 2 日以内に返信
-
Docs Timedelta
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
pandas-dev/pandas#69919 ·
メンテナーはふだん 1 日以内に返信
-
API documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
zephyrproject-rtos/west#1009 · コメント 2 件 ·
メンテナーはふだん 3 日以内に返信