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 xtreak
Recipients Caris Moses, Claudiu.Popa, and, cjw296, iforapsy, kushal.das, mariocj89, michael.foord, xtreak
Date 2019-10-14.17:40:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I tried your example as below using __name__. I received an AttributeError for which issue38473 in 3.7.5RC1 and 3.8.0RC1 and opened issue38473 and I am running my below code under that issue PR. For 3.7.4, I received manager.mock_calls to be an empty list since it doesn't contain the patch for this issue. Can you please confirm my results too.

➜  cpython git:(bpo38473) cat ../backups/
import unittest
from unittest import TestCase
from unittest.mock import patch, Mock, call, ANY

class MyObject:
    def __init__(self): = 0 = 0

    def set_foo(self, value): = value

    def set_bar(self, value): = value

def do_something():
    o = MyObject()
    return "something unrelated"

class MyObjectTest(TestCase):
    @patch(f"{__name__}.MyObject.set_bar", autospec=True)
    @patch(f"{__name__}.MyObject.set_foo", autospec=True)
    def test_do_something(self, mock_set_foo, mock_set_bar):
        manager = Mock()
        manager.attach_mock(mock_set_foo, "set_foo_func")
        manager.attach_mock(mock_set_bar, "set_bar_func")
        assert manager.mock_calls == [
            call.set_foo_func(ANY, 3),
            call.set_bar_func(ANY, 4),
        manager.assert_has_calls([call.set_foo_func(ANY, 3), call.set_bar_func(ANY, 4)])

if __name__ == "__main__":

➜  cpython git:(bpo38473) ./python ../backups/
Ran 1 test in 0.006s

Date User Action Args
2019-10-14 17:40:46xtreaksetrecipients: + xtreak, cjw296, michael.foord, Claudiu.Popa, kushal.das, and, mariocj89, iforapsy, Caris Moses
2019-10-14 17:40:46xtreaksetmessageid: <>
2019-10-14 17:40:46xtreaklinkissue21478 messages
2019-10-14 17:40:46xtreakcreate