Skip to content

I want a rule that will check pytest.approx parameters #254

@henzef

Description

@henzef

Rule request

Description

I think a rule to test that all arguments but the first of pytest.approx() are keyword arguments would be useful

example (bad):

assert get_some_value() == pytest.approx(10, 5)

example (very bad):

assert get_some_value() == pytest.approx(1.1, 0, 4, True)

example (good):

assert get_some_value() == pytest.approx(10, abs=5)
assert get_some_value() == pytest.approx(10, rel=0.5)

Rationale

We had several issues because people thought that "abs" was the first parameter and when they omitted the keyword argument, the checked tolerance was suddenly much larger.
Plus I think it makes reading the code much easier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions