Skip to content

--import-mode=importlib breaks assertion rewriting #12044

@y2kbugger

Description

@y2kbugger
[tool.pytest.ini_options]
minversion = "8.0"
python_files = "*.test.py"
addopts = [
    "--import-mode=importlib",
    ]

Using --import-mode=importlib is more lenient than the default import-mode, and so it allowed me to use *.test.py rather than a valid module name e.g. *_.test.py.

Everything seemed to work correctly except explanations were missing:

    def test_answer():
>       assert inc(3) == 5
E       AssertionError

insync/db.test.py:34: AssertionError

instead of

    def test_answer():
>       assert inc(3) == 5
E       assert 4 == 5
E        +  where 4 = inc(3)

insync/db_test.py:34: AssertionError

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: rewriterelated to the assertion rewrite mechanism

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions