Skip to content

Error when using non-unicode regular expression in parametrize argument #1437

Closed
@DRMacIver

Description

@DRMacIver

When running py.test 2.9.0 on Python 3.5.0 on Linux (but probably all other OSes and other Python 3 versions too) the following code raises an error:

import pytest
import re

@pytest.mark.parametrize('r', [re.compile(b'foo')])
def test_stuff(r):
    pass

The error raised is:

lib/python3.5/site-packages/_pytest/python.py:1136: in _idvalset
    return "-".join(this_id)
E   TypeError: sequence item 0: expected str instance, bytes found

Presumably some special case code for dealing with regular expressions that doesn't handle bytes ones.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueeasy issue that is friendly to new contributorstatus: criticalgrave problem or usability issue that affects lots of usersstatus: help wanteddevelopers would like help from experts on this topictopic: parametrizerelated to @pytest.mark.parametrizetype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions