Skip to content

Instantly share code, notes, and snippets.

@okken
Created August 23, 2016 22:32
Show Gist options
  • Save okken/7dd34e0fe0086788412d800213bf6cf1 to your computer and use it in GitHub Desktop.
Save okken/7dd34e0fe0086788412d800213bf6cf1 to your computer and use it in GitHub Desktop.
pytest paramterized ids cannot be integers. They could in 2.9.2
mport pytest
# -----------------------------------------
# To Demonstrate numerical ids not working
# -----------------------------------------
testdata = [( 1, 2), ( 2, 4)]
def times_2(x):
return x * 2
@pytest.mark.parametrize("x,expected", testdata, ids=('a','b'))
def test_ids_strings(x,expected):
'''works in both 3.0.0 and 2.9.2'''
assert times_2(x) == expected
@pytest.mark.parametrize("x,expected", testdata, ids=(1,2))
def test_ids_numbers(x,expected):
'''works in 2.9.2, crashes verbosely in 3.0.0'''
assert times_2(x) == expected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment