Skip to content

pytest raises an invalid UnicodeEncodeError in Python 2.7 #1085

Closed
@Themanwithoutaplan

Description

@Themanwithoutaplan

This looks like it has just crept into pytest 2.8.1.

I have a parametrised test where I'm passing in unicode, decoded from bytes. Pytest fails to even collect the test. This didn't used to happen (env's with 2.7.2 are running fine) and I'm pretty sure the code is legitimate across Python 2/3

class TestASCII:

    def test_valid(self, ascii):
        ascii.value = b'some text'
        assert ascii.value == b'some text'

    value = b'\xc3\xbc'.decode("utf-8")
    @pytest.mark.parametrize("value",
                             [
                                 value,
                                 10,
                                 []
                             ]
                             )
    def test_invalid(self, ascii, value):
        with pytest.raises(TypeError):
            ascii.value = value

Metadata

Metadata

Assignees

Labels

type: bugproblem that needs to be addressed

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions