[Python-Dev] How far to go with user-friendliness

Paul Moore p.f.moore at gmail.com
Tue Jul 14 21:39:08 CEST 2015

On 14 July 2015 at 20:27, Robert Collins <robertc at robertcollins.net> wrote:
> Well.
> I'd go further and just separate the APIs.
> mock.assert_called_with(a_mock, *args, **kwargs)
> mock can know how to poke under the covers (e.g. using
> __Mock_assert_called_with) without leaking it into the users objects.

As someone who makes limited use of mock, and therefore whose opinion
shouldn't carry too much weight, I like this option.

>> Given that it's way too late to take that path, I can see the value of
>> trying to detect common errors. Particularly as the result of failing
>> to do so is an apparently-passing test.
> We can add a new API and gradually deprecate the old one. With the
> presence of 'mock' as a rolling backport, this can be used by folk on
> Python 3.3 and 3.4 so they don't get locked into one release of Python
> or another.

You're right - I hadn't thought of this approach.

>> In effect, this patch is "reserving" all attributes starting with
>> "assert" or "assret" as actual methods of the mock object, and not
>> mocked attributes.
> Yes, and thats ugly. OTOH it caught hundreds of useless tests in
> OpenStack when this got ported into mock 1.1.0.

... which I guess counts as strong evidence that this *is* a common
typo, at least in certain contexts.


More information about the Python-Dev mailing list