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

None in paramtrized test id will use automatically generated id #1468

merged 7 commits into from Mar 20, 2016


None yet
2 participants

palaviv commented Mar 20, 2016

This pull request is allowing the user to pass None as a specific test id of parametrize. If a test id is None the specific test id will be automatically calculated.

import pytest
@pytest.mark.parametrize(("a,b"), [(1,1), (1,1), (1,2)],
                         ids=["basic", None, "advanced"])  
def test_function(a, b):
    assert a == b

This will result in the following tests:

  • test_function[basic]
  • test_function[1-1]
  • test_function[advanced]

As a side effect of this PR i noticed that when you pass the same test id we recieve a duplicate test:

import pytest
@pytest.mark.parametrize("a,b", [(1,2), (3,4)], ids=["a", "a"])
def test_a(a,b):

Currently result in the test:
- test_a[a]
- test_a[a]

After this change the result will be:
- test_a[0a]
- test_a[1a]

Same as when a ids callable return the same value.


This comment has been minimized.


RonnyPfannschmidt commented Mar 20, 2016

excellent work, as followup we might want to take a look at where to put the prefix

RonnyPfannschmidt added a commit that referenced this pull request Mar 20, 2016

Merge pull request #1468 from palaviv/allow-none-as-parametrized-test-id
None in paramtrized test id will use automatically generated id

@RonnyPfannschmidt RonnyPfannschmidt merged commit da10451 into pytest-dev:features Mar 20, 2016

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment