>>> @mock.patch('datetime.date.today')
... def test():
... datetime.date.today.return_value = date(2010, 1, 1)
... print(datetime.date.today())
...
>>> test()
Traceback (most recent call last):
File "/usr/lib/python3.6/unittest/mock.py", line 1175, in patched
arg = patching.__enter__()
File "/usr/lib/python3.6/unittest/mock.py", line 1338, in __enter__
setattr(self.target, self.attribute, new_attr)
TypeError: can't set attributes of built-in/extension type 'datetime.date'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/unittest/mock.py", line 1196, in patched
patching.__exit__(*exc_info)
File "/usr/lib/python3.6/unittest/mock.py", line 1358, in __exit__
setattr(self.target, self.attribute, self.temp_original)
TypeError: can't set attributes of built-in/extension type 'datetime.date'
но ведь код неправильный
Aragaer
Anonymous
Tishka17
Алексей
Александр
c
Artyom
Sergei
Alex