issue250 unicode/str mixes in parametrization names and values now works

This commit is contained in:
holger krekel 2013-02-12 23:30:34 +01:00
parent 296f752cca
commit d0e18ac63f
4 changed files with 15 additions and 1 deletions

View File

@ -1,6 +1,8 @@
Changes between 2.3.4 and 2.3.5dev
-----------------------------------
- issue250 unicode/str mixes in parametrization names and values now works
- issue257, assertion-triggered compilation of source ending in a
comment line doesn't blow up in python2.5 (fixed through py>=1.4.13.dev6)

View File

@ -732,7 +732,7 @@ def idmaker(argnames, argvalues):
this_id = []
for nameindex, val in enumerate(valset):
if not isinstance(val, (float, int, str)):
this_id.append(argnames[nameindex]+str(valindex))
this_id.append(str(argnames[nameindex])+str(valindex))
else:
this_id.append(str(val))
idlist.append("-".join(this_id))

View File

@ -1,3 +1,4 @@
import pytest, py, sys
from _pytest import python as funcargs
from _pytest.python import FixtureLookupError
@ -106,6 +107,7 @@ class TestMetafunc:
assert metafunc._calls[2].id == "x1-a"
assert metafunc._calls[3].id == "x1-b"
@pytest.mark.issue250
def test_idmaker_autoname(self):
from _pytest.python import idmaker
result = idmaker(("a", "b"), [("string", 1.0),
@ -115,6 +117,9 @@ class TestMetafunc:
result = idmaker(("a", "b"), [(object(), 1.0),
(object(), object())])
assert result == ["a0-1.0", "a1-b1"]
# unicode mixing, issue250
result = idmaker((u"a", "b"), [({}, '\xc3\xb4')])
assert result == ['a0-\xc3\xb4']
def test_addcall_and_parametrize(self):

View File

@ -50,6 +50,13 @@ changedir=.
commands=py.test --doctest-modules _pytest
deps=
[testenv:py32]
deps=
:pypi:nose
[testenv:py33]
deps=
:pypi:nose
[testenv:doc]
basepython=python