Message377140
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() |
|
Date |
User |
Action |
Args |
2020-09-18 21:50:35 | terry.reedy | set | recipients:
+ terry.reedy, michael.foord, xtreak, melwitt |
2020-09-18 21:50:35 | terry.reedy | set | messageid: <1600465835.17.0.458820364256.issue41768@roundup.psfhosted.org> |
2020-09-18 21:50:35 | terry.reedy | link | issue41768 messages |
2020-09-18 21:50:35 | terry.reedy | create | |
|