Skip to content

Add alias for parametrize or provide better error reporting #463

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

Closed
pytestbot opened this issue Feb 14, 2014 · 5 comments
Closed

Add alias for parametrize or provide better error reporting #463

pytestbot opened this issue Feb 14, 2014 · 5 comments
Labels
type: enhancement new feature or API change, should be merged into features branch

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Nenad Ognjanovic (BitBucket: bgr_, GitHub: bgr_)


Consider adding an alias parameterize for parametrize, since it's a valid spelling but using it in pytest will give a misleading error message - for the code below error message will say "fixture 'arg' not found", not mentioning that parameterize doesn't exist.

#!python

import pytest

@pytest.mark.parameterize('arg, expected', [
    (1, 1),
])
def test_confusion(arg, expected):
    assert arg == expected

@pytestbot
Copy link
Contributor Author

Original comment by Brianna Laugher (BitBucket: pfctdayelise, GitHub: pfctdayelise):


It is quite a confusing message. Another option might be at least adding a warning for common misspellings. I will note that in the meantime, you can sidestep the issue by adding this to your conftest.py:

#!python

import pytest
pytest.mark.parameterize = pytest.mark.parametrize

@pytestbot
Copy link
Contributor Author

Original comment by Tom Dryer (BitBucket: tdryer, GitHub: tdryer):


I just got bit by this too. Another solution would be to move parametrize to a module that isn't generating members automatically, so misspelling it will give a clear error.

@pytestbot
Copy link
Contributor Author

Original comment by Brianna Laugher (BitBucket: pfctdayelise, GitHub: pfctdayelise):


Issue #695 was marked as a duplicate of this issue.

@pytestbot
Copy link
Contributor Author

Original comment by Brianna Laugher (BitBucket: pfctdayelise, GitHub: pfctdayelise):


Well the release was made today so this would seem to be fixed :)

@pytestbot pytestbot added the type: enhancement new feature or API change, should be merged into features branch label Jun 15, 2015
@mbarkhau
Copy link

And here I thought I was going insane. Thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

2 participants