Skip to content
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

Printing detailed diff with pytest.approx fails due to ± character #2111

Closed
kerrick-lyft opened this issue Dec 1, 2016 · 2 comments
Closed
Labels
type: bug problem that needs to be addressed

Comments

@kerrick-lyft
Copy link

OS: OS X 10.11.6 (also present on Ubuntu 14.04)
Python version: 2.7.12
pytest version: 3.0.4
Output of pip list:

pip (9.0.1)
py (1.4.31)
pytest (3.0.4)
setuptools (30.0.0)
wheel (0.30.0a0)

This code:

import pytest

def test_foo():
    assert [3] == [pytest.approx(4)]

produces the below output. It looks like the detailed diff can't render due to the ± character in the __repr__ of pytest.approx.

(venv) ➜  /tmp py.test pytest_broken.py 
============================= test session starts ==============================
platform darwin -- Python 2.7.12, pytest-3.0.4, py-1.4.31, pluggy-0.4.0
rootdir: /private/tmp, inifile: 
plugins: cov-2.2.1, mock-0.11.0
collected 1 items 

pytest_broken.py F

=================================== FAILURES ===================================
___________________________________ test_foo ___________________________________

    def test_foo():
>       assert [3] == [pytest.approx(4)]
E       assert [3] == [4 ± 4.0e-06]
E         (pytest_assertion plugin: representation of details failed.  Probably an object has a faulty __repr__.)
E         /usr/local/lib/python2.7/site-packages/_pytest/assertion/util.py:228: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 2: ordinal not in range(128)

pytest_broken.py:4: AssertionError
============================ pytest-warning summary ============================
WC1 None pytest_funcarg__cov: declaring fixtures using "pytest_funcarg__" prefix is deprecated and scheduled to be removed in pytest 4.0.  Please remove the prefix and use the @pytest.fixture decorator instead.
================= 1 failed, 1 pytest-warnings in 0.03 seconds ==================

@nicoddemus
Copy link
Member

Thanks!

@nicoddemus
Copy link
Member

(You can update your pytest-cov plugin to get rid of that warning 😉 )

@nicoddemus nicoddemus added the type: bug problem that needs to be addressed label Dec 2, 2016
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Dec 2, 2016
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Dec 2, 2016
nicoddemus added a commit to nicoddemus/pytest that referenced this issue Dec 2, 2016
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

2 participants