This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients melwitt, michael.foord, terry.reedy, xtreak
Date 2020-09-18.21:50:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1600465835.17.0.458820364256.issue41768@roundup.psfhosted.org>
In-reply-to
Content
Without lines numbers, I cannot test which of the two identical asserts failed. Either comments or msg arguments will differentiate.  Nor can I run snippets from two different files. Here is a minimal reproducible self-contained code that demonstrates the claim (which I verified on 3.9 and current master).

import unittest
from unittest.mock import Mock

class SomethingElse(object):
    def __init__(self):
        self._instance = None

    @property
    def instance(self):
        if not self._instance:
            self._instance = 'object'

class Test(unittest.TestCase):

    def test_property_not_called_with_spec_mock(self):
        obj = SomethingElse()
        self.assertIsNone(obj._instance, msg='before') # before
        mock = Mock(spec=obj)
        self.assertIsNone(obj._instance, msg='after') # after

unittest.main()
History
Date User Action Args
2020-09-18 21:50:35terry.reedysetrecipients: + terry.reedy, michael.foord, xtreak, melwitt
2020-09-18 21:50:35terry.reedysetmessageid: <1600465835.17.0.458820364256.issue41768@roundup.psfhosted.org>
2020-09-18 21:50:35terry.reedylinkissue41768 messages
2020-09-18 21:50:35terry.reedycreate