Skip to content

Immediate failure if a malformed pyproject.toml exists in a parent directory #9730

@jrs65

Description

@jrs65
  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible

I've been having obscure pytest failures giving only the message ERROR: Invalid value (at line 9, column 19). The issue seems to occur if there is a malformed pyproject.toml file in a parent directory (which I had several levels higher up in my directory tree). I don't think failing in this case itself is necessarily an issue, but the error message gives no clue as to what the problem is other than implying that it's a file somewhere.

Steps to reproduce:

$ pytest
============================= test session starts ==============================
platform darwin -- Python 3.9.9, pytest-7.0.1, pluggy-1.0.0
rootdir: /Users/richard/tmp/testpytest/testdir
plugins: anyio-2.2.0
collected 0 items

============================ no tests ran in 0.01s =============================

$ echo "\"" > ../pyproject.toml

$ pytest
ERROR: Illegal character '\n' (at line 1, column 2)

Earlier versions of pytest (tested 6.1.2) did not seem to have quite the same problem as they at least gave the stack trace from the TOML parser which have a slightly better hint what the problem was. In the end that was how I figured out what was going on.

Pip packages:

Package    Version
---------- -------
attrs      21.4.0
iniconfig  1.1.1
packaging  21.3
pip        22.0.3
pluggy     1.0.0
py         1.11.0
pyparsing  3.0.7
pytest     7.0.1
setuptools 60.9.3
tomli      2.0.1
wheel      0.37.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: configrelated to config handling, argument parsing and config filetopic: reportingrelated to terminal output and user-facing messages and errorstype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions