New issue 514: Error constructing message for unhooked assertion failure based on private variable https://bitbucket.org/hpk42/pytest/issue/514/error-constructing-message-for-unhooked
Jurko Gospodnetić: In the following scenario: File: ```test_me.py``` ``` #!python from outsider import Outsider class Insider: def __init__(self): self.__private = 5 assert self.__private == 6 def test_insider(): Insider() def test_outsider(): Outsider() ``` File: ``outsider.py`` ``` #!python class Outsider: def __init__(self): self.__private = 5 assert self.__private == 6 ``` when running the tests using ``pytest --tb=short`` you get the following output: ``` #!text ================================== FAILURES =================================== ________________________________ test_insider _________________________________ test_me.py:9: in test_insider > Insider() test_me.py:6: in __init__ > assert self.__private == 6 E assert 5 == 6 E + where 5 = <test_me.Insider object at 0x00000000034460B8>.__private ________________________________ test_outsider ________________________________ test_me.py:12: in test_outsider > Outsider() outsider.py:4: in __init__ > assert self.__private == 6 E AssertionError: AttributeError: <outsider.Outsider object at 0x0000000003446AC8>.__private << 'Outsider' object has no attribute '__private' ========================== 2 failed in 0.08 seconds =========================== ``` As you can see, ``pytest`` attempts to construct the assertion failure description message for the failed ``test_outsider`` test but does not access the private ``__private`` attribute correctly which should have been accessed as ``_Outsider__private``. Hope this helps. Best regards, Jurko Gospodnetić _______________________________________________ pytest-commit mailing list pytest-commit@python.org https://mail.python.org/mailman/listinfo/pytest-commit