[pytest-dev] fixture params must be immutable?
Ofer Nave
onave at dyn.com
Mon Apr 8 16:57:54 CEST 2013
Been using pytest for a few days and enjoying it greatly. However, the
last bit of code I wrote just blew up with "INTERNALERROR> TypeError:
unhashable type: 'dict'".
It seems that if you parameterize a fixture function, it must be with a
list of immutable values. This works:
@pytest.fixture(params=[1, 2, 3])
def foo(request):
return request.param
def bar(foo):
assert foo
This doesn't:
@pytest.fixture(params=[{a:1}, {a:2}, {a:3}])
def foo(request):
return request.param
def bar(foo):
assert foo
...because dict is immutable.
I didn't see this requirement mentioned in the docs, and I don't
understand why it would be the case. Looking for enlightenment.
-ofer
More information about the Pytest-dev
mailing list