Skip to content

Exclude some test modules from assertion rewriting #2203

Closed
@nicoddemus

Description

@nicoddemus

Sometimes users do some "black magic" like patching builtins (for example #2180) and that might completely break pytest.

While of course we should not encourage too much black magic, I was wondering if we could alleviate the problem for users which don't want or can't change their tests to disable assertion rewriting for some of the test modules.

I was thinking of something like the # encoding comment used by Python to declare the encoding of a file. An alternative would be to list some test files on pytest.ini, but I think the comment is better because it is written in the file itself, rather than far away from it.

How about # pytest-no-rewrite or something like this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: feature-branchnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions