Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate unpacking marks in parameter values and provide a clean alternative #1748

Closed
RonnyPfannschmidt opened this issue Jul 21, 2016 · 3 comments

Comments

@RonnyPfannschmidt
Copy link
Member

RonnyPfannschmidt commented Jul 21, 2016

the mechanism we use to makr parameter sets

like

import pytest
@pytest.mark.parametrize(("n", "expected"), [
  (1, 2),
  pytest.mark.foo((2, 3)),
  (3, 4),
])
def test_increment(n, expected):
    assert n + 1 == expected

means that we have to unpack mark decorator objects in a very error prone/messy way
and in addition we end up with the inability to safely use function that way

i propose replacing it with something like

import pytest
@pytest.mark.parametrize(("n", "expected"), [
  (1, 2),
  pytest.marked_value((2, 3)), marks=pytest.mark.foo)
  (3, 4),
])
def test_increment(n, expected):
    assert n + 1 == expected
@The-Compiler
Copy link
Member

Assuming you mean pytest.marked_value((2, 3), marks=pytest.mark.foo) (without the extra )), that sounds like a good idea.

It'd also make using marks with arguments nicer IMHO:

before: pytest.mark.xfail(reason='...')((1, 2))
after: pytest.marked_value((1, 2), marks=pytest.mark.xfail(reason='...'))

@RonnyPfannschmidt
Copy link
Member Author

laos a "fun detail" currently pytest.mark.xfail(reason='...')((1, 2)) is equivalent to pytest.mark.xfail((1, 2), reason='...')

which is just plain horror

@RonnyPfannschmidt
Copy link
Member Author

fixed in #1921

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants