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

when testing encodings for ansible - windows hosts error occurs [venv/lib/python3.12/site-packages/testinfra/backend/ansible.py:62: KeyError]

Đang mở
#786 0 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ó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
ansible, python

Hướng nghiên cứu

Start with test_infra.py and trace the failure through testinfra/backend/ansible.py:get_encoding, backend/base.py, and utils/ansible_runner.py:run_module. Reproduce the encoding check against a Windows host and inspect the captured Ansible result. Done means the Windows encoding test no longer raises the reported KeyError or related failure.

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

Mô tả

image

>       result = host.ansible(
            "win_shell",
            f"Get-Content -Path '{file_path}' | Out-String",
            check=False,
            become=True,
            become_user="vlan8user",
            become_method="runas",
        )

test_infra.py:20: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
venv/lib/python3.12/site-packages/testinfra/modules/ansible.py:43: in wrapper
    return func(self, *args, **kwargs)
venv/lib/python3.12/site-packages/testinfra/modules/ansible.py:110: in __call__
    result = self._host.backend.run_ansible(
venv/lib/python3.12/site-packages/testinfra/backend/ansible.py:72: in run_ansible
    result = self.ansible_runner.run_module(
venv/lib/python3.12/site-packages/testinfra/utils/ansible_runner.py:411: in run_module
    with open(fpath, "r", encoding=get_encoding()) as f:
venv/lib/python3.12/site-packages/testinfra/backend/ansible.py:70: in get_encoding
    return self.encoding
venv/lib/python3.12/site-packages/testinfra/backend/base.py:303: in encoding
    self._encoding = self.get_encoding()
venv/lib/python3.12/site-packages/testinfra/backend/base.py:283: in get_encoding
    cmd = self.run(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <testinfra.backend.ansible.AnsibleBackend object at 0x7f0793cdf9e0>
command = "python3 -c 'import locale;print(locale.getpreferredencoding())'"
args = ('python3',), kwargs = {'encoding': None}
out = {'ansible_facts': {'discovered_interpreter_python': '/usr/bin/python3'}, 'changed': False, 'module_stderr': 'Exception...Operation: (:) [], RuntimeException\r\n    + FullyQualifiedErrorId : BadExpression\r\n \r\n', 'module_stdout': '', ...}

    def run(
    ```
Ngôn ngữ chính
Python
Star
2.5k
Fork
360
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

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 pytest-dev/pytest-testinfra

Tất cả issue của pytest-dev/pytest-testinfra

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.