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 lisroach
Recipients lisroach, xtreak
Date 2019-09-26.05:02:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1569474130.28.0.0378830797463.issue38163@roundup.psfhosted.org>
In-reply-to
Content
This should be simple to do, after https://github.com/python/cpython/pull/16060 we can add:

            elif self._mock_methods and _new_name in self._mock_methods:
                # Methods that are not in _spec_asyncs are normal methods
                klass = MagicMock

to _get_child_mocks and test with:

    def test_normal_methods_on_class(self):
        am = AsyncMock(AsyncClass)
        self.assertIsInstance(am.async_method, AsyncMock)
        self.assertIsInstance(am.normal_method, MagicMock)

This might be starting to make _get_child_mocks too complicated, and no longer follows the default "child mocks are the same as their parent". I am not sure how to redefine _get_child_mocks without needing to double up a lot of code to support MagicMocks having AsyncMock child_mocks as well.
History
Date User Action Args
2019-09-26 05:02:10lisroachsetrecipients: + lisroach, xtreak
2019-09-26 05:02:10lisroachsetmessageid: <1569474130.28.0.0378830797463.issue38163@roundup.psfhosted.org>
2019-09-26 05:02:10lisroachlinkissue38163 messages
2019-09-26 05:02:10lisroachcreate