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

Incorrect indentation of docstrings in code displayed in assert failures #3493

Open
VorpalBlade opened this issue May 22, 2018 · 2 comments
Open
Labels
topic: reporting related to terminal output and user-facing messages and errors type: bug problem that needs to be addressed

Comments

@VorpalBlade
Copy link

The indentation in the displayed code is incorrect for docstrings in class members in the assertion errors.

$ py.test
===================================== test session starts =====================================
platform linux -- Python 3.5.2, pytest-3.5.1, py-1.5.3, pluggy-0.6.0
rootdir: /home/user/tmp, inifile:
collected 2 items                                                                             

test_dummy.py FF                                                                        [100%]

========================================== FAILURES ===========================================
___________________________________________ test_a ____________________________________________

    def test_a():
        """Foo bar
        quux
        """
>       assert False
E       assert False

test_dummy.py:6: AssertionError
______________________________________ TestClass.test_b _______________________________________

self = <test_dummy.TestClass object at 0x7fd93fbefa58>

    def test_b(self):
        """Foo bar
            quux
            """
>       assert False
E       assert False

test_dummy.py:13: AssertionError
================================== 2 failed in 0.03 seconds ===================================

Notice the extra indentation in the error report for test_b. (See the attached file for the code, had to add .txt to make github accept the file though.)

test_dummy.py.txt

System information:

$ pip list
Package        Version
-------------- -------
attrs          18.1.0 
more-itertools 4.1.0  
pip            10.0.1 
pkg-resources  0.0.0  
pluggy         0.6.0  
py             1.5.3  
pytest         3.5.1  
setuptools     39.2.0 
six            1.11.0 
$ uname -a
Linux tmgarn 4.4.0-124-generic #148-Ubuntu SMP Wed May 2 13:00:18 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="16.04.4 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.4 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
@pytestbot
Copy link
Contributor

GitMate.io thinks possibly related issues are #1 (assert reinterpretation fails for some code layouts), #61 (Assert rewriting failure for multiple 'and'), #577 (assert rewritereinterp failure with tripple quotes), #7 (assert failure inside doctest doesn't prettyprint), and #715 (Full diff of sequences should be displayed on assertion failures when verbose).

@pytestbot pytestbot added the type: bug problem that needs to be addressed label May 22, 2018
@nicoddemus
Copy link
Member

Thanks @VorpalBlade for the report!

@nicoddemus nicoddemus added the topic: reporting related to terminal output and user-facing messages and errors label May 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: reporting related to terminal output and user-facing messages and errors type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

3 participants