Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#656 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
38/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
powershell, python
Ambito
testing-qa

Direzione di ricerca

Inizia riproducendo pytest-bdd generate features/installer.feature > installer_step_definitions/test_installer_steps.py in PowerShell, quindi esegui pytest e verifica la codifica del file generato. Confronta l’output di PowerShell con quello di cmd e con le versioni convertite manualmente; il lavoro è completato quando il file degli step generato viene accettato durante la raccolta di pytest senza errori di byte nulli o di codifica.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
Python
Stelle
1.5k
Fork
251
Merge medio
43m
PR unite (30g)
2

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pytest-dev/pytest-bdd

Tutte le issue di pytest-dev/pytest-bdd

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.