Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Step file generated from powershell throws error on collection - not UTF-8 encoded

オープン
#656 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
powershell, python
領域
testing-qa

調査の方向性

まず、PowerShell で pytest-bdd generate features/installer.feature > installer_step_definitions/test_installer_steps.py を再現し、次に pytest を実行して生成されたファイルのエンコーディングを確認します。PowerShell の出力を cmd の出力および手動で変換したバージョンと比較します。完了の条件は、生成された step ファイルが pytest のコレクション中に null バイトやエンコーディングのエラーなしで受け入れられることです。

索引モデルが issue の本文から書いたものです。

説明

awaiting response

Generate in powershell with: with: pytest-bdd generate features/installer.feature > installer_step_definitions/test_installer_steps.py
Run with: pytest

OBS: During test collection error occurs as below. The same file test_installer_steps.py created in VS code and the same code pasted from Notepad++ works.

Note: If I create file by hand and overwrite it by auto generated file this happens:

image

Original encoding

image

When I convert to UTF-8 it works fine or if I run in cmd

VS Code encoding is UTF-8
image

ENV:
VS Code
Python 3.12

packages

Package Version


colorama 0.4.6
iniconfig 2.0.0
Mako 1.3.0
MarkupSafe 2.1.3
packaging 23.2
parse 1.19.1
parse-type 0.6.2
pip 23.3.1
pluggy 1.3.0
pytest 7.4.3
pytest-bdd 7.0.0
six 1.16.0
typing_extensions 4.8.0

.venv\Lib\site-packages_pytest\assertion\rewrite.py:359:


source = b'\xff\xfe"\x00"\x00"\x00I\x00n\x00s\x00t\x00a\x00l\x00l\x00e\x00r\x00 \x00f\x00e\x00a\x00t\x00u\x00r\x00e\x00 \x00t\x...\x00o\x00t\x00I\x00m\x00p\x00l\x00e\x00m\x00e\x00n\x00t\x00e\x00d\x00E\x00r\x00r\x00o\x00r\x00\r\x00\n\x00\r\x00\n\x00'
filename = 'C:\\Users\\vsypniewski-tom\\source\\repos\\xcd-bdd\\installer_step_definitions\\test_installer_steps.py', mode = 'exec'

    def parse(source, filename='<unknown>', mode='exec', *,
              type_comments=False, feature_version=None):
        """
        Parse the source into an AST node.
        Equivalent to compile(source, filename, mode, PyCF_ONLY_AST).
        Pass type_comments=True to get back type comments where the syntax allows.
        """
        flags = PyCF_ONLY_AST
        if type_comments:
            flags |= PyCF_TYPE_COMMENTS
        if feature_version is None:
            feature_version = -1
        elif isinstance(feature_version, tuple):
            major, minor = feature_version  # Should be a 2-tuple.
            if major != 3:
                raise ValueError(f"Unsupported major version: {major}")
            feature_version = minor
        # Else it should be an int giving the minor version for 3.x.
>       return compile(source, filename, mode, flags,
                       _feature_version=feature_version)
E       SyntaxError: source code string cannot contain null bytes

..\..\..\AppData\Local\Programs\Python\Python312\Lib\ast.py:52: SyntaxError

The above exception was the direct cause of the following exception:

cls = <class '_pytest.runner.CallInfo'>, func = <function pytest_make_collect_report.<locals>.<lambda> at 0x000002367EB0F4C0>, when = 'collect', reraise = None
主要言語
Python
スター
1.5k
フォーク
251
平均マージ
43分
マージ済み PR(30日)
2

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pytest-dev/pytest-bdd のほかの issue

pytest-dev/pytest-bdd の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。