<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 11/20/2012 5:08 PM, Martin Pool wrote:<br>
<blockquote
cite="mid:CAA9uavBk+PKcQuOwEZq-HtF6xC3u8RjOFEH_da3wJPJewNAK=Q@mail.gmail.com"
type="cite">On 21 November 2012 09:03, Martin Pool <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:mbp@sourcefrog.net" target="_blank">mbp@sourcefrog.net</a>></span>
wrote:<br>
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_extra">
<div class="gmail_quote">
<div class="im">On 21 November 2012 08:47, Michael <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:mock@webhippo.net" target="_blank">mock@webhippo.net</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
I would like to respectfully answer this:<br>
</blockquote>
</div>
<div>It doesn't look like you succeeded in answering
respectfully.</div>
<div class="im">
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
This is a super un-useful answer.<br>
<br>
1. Yes it worked in 0.7.2<br>
2. No the docs did not mention the __init__/super
was call was required. For all we knew it was not
required.<br>
3. The docs also do not mention like all kinds of
things, like that one should step on one foot while
using mock ... that does not mean we should do them.</blockquote>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>That's true; nor does it mention you must have Python
installed, or your computer must be switched on. I don't
think it would be useful for every Python library's
documentation to repeat the basics of how to use Python.</div>
<div><br>
</div>
<div>I don't think super constructor calls are an especially
well designed aspect of Python, because the default behavior
is generally not what you want (not to mention multiple
inheritance.) But, it is what it is, and code that doesn't
call upwards is generally wrong already.</div>
<div><br>
</div>
</div>
</div>
</blockquote>
<br>
I agree: this is common Python practice. If you are subclassing,
you should initialize your parent. Mock 0.7.2 must not have had any
attributes initialized in its constructor. Now in 0.8 it does. If
you subclass Mock, you must call Mock.__init__ to properly
initialize the base class. It is also easy to overlook this step,
and to have bugs introduced later as a result.<br>
<br>
<blockquote
cite="mid:CAA9uavBk+PKcQuOwEZq-HtF6xC3u8RjOFEH_da3wJPJewNAK=Q@mail.gmail.com"
type="cite">
<div class="gmail_extra">
<div class="gmail_quote">
<div>I expect if you sent a patch to Mock that does mention
this they'd probably take it.</div>
</div>
<div><br>
</div>
</div>
</blockquote>
<br>
If I were the author of Mock and got this doc patch, I would add it
as, "And of course, as with all subclassing in Python, don't forget
to call Mock's __init__ method."<br>
<br>
--Ned.<br>
<br>
PS: I understand the idea that by default the parent should get
initialized, but explicit is better than implicit, and invoking the
parent's __init__ explicitly gives you some control over where in
the child's __init__ it is invoked, what arguments it gets, and so
on.<br>
<br>
<blockquote
cite="mid:CAA9uavBk+PKcQuOwEZq-HtF6xC3u8RjOFEH_da3wJPJewNAK=Q@mail.gmail.com"
type="cite">
<div class="gmail_extra">-- <br>
Martin<br>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
testing-in-python mailing list
<a class="moz-txt-link-abbreviated" href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a>
<a class="moz-txt-link-freetext" href="http://lists.idyll.org/listinfo/testing-in-python">http://lists.idyll.org/listinfo/testing-in-python</a>
</pre>
</blockquote>
<br>
</body>
</html>