Skip to content

pytest raises an invalid UnicodeEncodeError in Python 2.7 #1085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Themanwithoutaplan opened this issue Sep 29, 2015 · 9 comments
Closed

pytest raises an invalid UnicodeEncodeError in Python 2.7 #1085

Themanwithoutaplan opened this issue Sep 29, 2015 · 9 comments
Assignees
Labels
type: bug problem that needs to be addressed
Milestone

Comments

@Themanwithoutaplan
Copy link

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
@nicoddemus
Copy link
Member

Thanks for the report! I will take a look as soon as possible, it is clearly related to the fix done for #1030.

@nicoddemus nicoddemus self-assigned this Sep 29, 2015
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Sep 29, 2015
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Sep 30, 2015
@nicoddemus
Copy link
Member

@sloria and @Themanwithoutaplan, could you please verify if the branch #1092 solves this problem in your test suites? Thanks!

You can install it directly into your environment:

pip install git+https://github.com/nicoddemus/pytest@param-ids-fix

@sloria
Copy link

sloria commented Sep 30, 2015

Confirmed--that branch fixes the problem on my test suite. Thanks for the quick response!

@Themanwithoutaplan
Copy link
Author

Not sure how to run tox against this branch,

@RonnyPfannschmidt
Copy link
Member

@Themanwithoutaplan you can probably just copy the git url @nicoddemus posted into the deps section

@Themanwithoutaplan
Copy link
Author

What deps section? I don't see one in the PR.

@The-Compiler
Copy link
Member

@Themanwithoutaplan the deps section in your project's tox.ini - you should be able to simply replace pytest with git+https://github.com/nicoddemus/pytest@param-ids-fix there.

@Themanwithoutaplan
Copy link
Author

@The-Compiler thanks. Tests no longer fail with that.

@jodal
Copy link

jodal commented Oct 4, 2015

The #1030 change in 2.8.1 broke my test suite too. The branch linked here solves the problem. Hoping for a quick 2.8.2 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

6 participants