[Pytest-commit] Issue #523: ValueError: duplicate arg (hpk42/pytest)

James Mills issues-reply at bitbucket.org
Thu Jun 5 04:38:58 CEST 2014


New issue 523: ValueError: duplicate arg
https://bitbucket.org/hpk42/pytest/issue/523/valueerror-duplicate-arg

James Mills:

**test_foo.py**:
```
#!python
def pytest_generate_tests(metafunc):
    for level in ("level_{0:d}".format(level) for level in [1, 2, 3]):
        argvalues = [
            ["1", "2"],
            ["1", "2"],
        ]

        ids = [
            "{0:s}_test1".format(level),
            "{0:s}_test2".format(level),
        ]

        metafunc.parametrize(["a", "b"], argvalues, ids=ids)


def test(a, b):
    assert a < b
```

**Output:**
```
#!bash
$ py.test -x -s -v tests/test_foo.py
============================= test session starts ==============================
platform darwin -- Python 2.7.6 -- py-1.4.20 -- pytest-2.6.0.dev1 -- /Users/s2092651/.virtualenvs/jsonselect/bin/python
plugins: cov
collected 0 items / 1 errors

==================================== ERRORS ====================================
______________________ ERROR collecting tests/test_foo.py ______________________
tests/test_foo.py:13: in pytest_generate_tests
>           metafunc.parametrize(["a", "b"], argvalues, ids=ids)
../../.virtualenvs/jsonselect/lib/python2.7/site-packages/_pytest/python.py:828: in parametrize
>                                    param_index)
../../.virtualenvs/jsonselect/lib/python2.7/site-packages/_pytest/python.py:709: in setmulti
>           self._checkargnotcontained(arg)
../../.virtualenvs/jsonselect/lib/python2.7/site-packages/_pytest/python.py:692: in _checkargnotcontained
>           raise ValueError("duplicate %r" %(arg,))
E           ValueError: duplicate 'a'
=========================== 1 error in 0.03 seconds ============================
```




More information about the pytest-commit mailing list