Merged in pfctdayelise/pytest (pull request #38)

A couple of improvements to parametrize
This commit is contained in:
holger krekel
2013-07-16 15:30:48 +02:00
2 changed files with 35 additions and 3 deletions

View File

@@ -2,6 +2,7 @@
import py
import inspect
import sys
from types import NoneType
import pytest
from _pytest.main import getfslineno
from _pytest.mark import MarkDecorator, MarkInfo
@@ -709,6 +710,9 @@ class Metafunc(FuncargnamesCompatAttr):
raise ValueError("%r uses no fixture %r" %(
self.function, arg))
valtype = indirect and "params" or "funcargs"
if ids and len(ids) != len(argvalues):
raise ValueError('%d tests specified with %d ids' %(
len(argvalues), len(ids)))
if not ids:
ids = idmaker(argnames, argvalues)
newcalls = []
@@ -762,7 +766,7 @@ def idmaker(argnames, argvalues):
for valindex, valset in enumerate(argvalues):
this_id = []
for nameindex, val in enumerate(valset):
if not isinstance(val, (float, int, str)):
if not isinstance(val, (float, int, str, bool, NoneType)):
this_id.append(str(argnames[nameindex])+str(valindex))
else:
this_id.append(str(val))