Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

test_lazy_choices_help fails on Python 3.14

Đang mở
#1,641 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
52/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
cli, testing-qa

Hướng nghiên cứu

Bắt đầu với tests/test_cli_utils.py::test_lazy_choices_help và tái hiện lỗi bằng Python 3.14 cùng các lệnh uv được liệt kê. Theo dõi quá trình khởi tạo ArgumentParser và LazyChoices để tìm hiểu lý do getter được gọi quá sớm, sau đó làm cho test chạy thành công mà không thay đổi hành vi lazy được mong đợi của nó.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug new

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.

Ngôn ngữ chính
Python
Star
38.6k
Fork
4k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của httpie/cli

Tất cả issue của httpie/cli

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.