<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">I can’t share real code, but what I can tell you is that it’s django code – we’ve got a lot multiple inheritance going on with class based views. None of these
 methods are going to stop having super calls (or if they do, that will very much be the exception).
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">As to behaviour-driven testing: I usually use that, and minimize mocks. With class based views, each class implements a different behaviour, and the inheritance
 hierarchy is fairly deep (at least three classes). Accordingly, each method really does need to be tested independently, because it is not that the method uses super to implement one behaviour; rather it is triggering the next behaviour, whatever that may
 be. <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> David Stanek [mailto:dstanek@dstanek.com]
<br>
<b>Sent:</b> Wednesday, August 13, 2014 7:13 PM<br>
<b>To:</b> Marcin Tustin<br>
<b>Cc:</b> Ned Batchelder; testing-in-python@lists.idyll.org<br>
<b>Subject:</b> Re: [TIP] Unit testing functions which call super<o:p></o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<p class="MsoNormal">On Wed, Aug 13, 2014 at 6:54 PM, Marcin Tustin &lt;<a href="mailto:Marcin.Tustin@dealertrack.com" target="_blank">Marcin.Tustin@dealertrack.com</a>&gt; wrote:<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">It’s not&nbsp; question of terminology. What happens if I let the test call it’s super is impossible to
 anticipate (but in practice will be some kind of exception). Even if it successfully calls the super methods, the output won’t be defined by this code, but some other code, so I can’t usefully test anything about it other than its type. If it doesn’t work,
 then I have to deal with those exceptions, but then I can’t very well distinguish between exceptions originating in the code I’m testing, and exceptions in the super methods. It’s all the usual reasons for mocking out calls.</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<p class="MsoNormal">I think about my tests differently. I don't care how the feature is implemented all I care about is if it works. Mocking super means that you can't refactor your code without changing tests.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">Do you have any real code to share? &nbsp;I suspect that the method you had in your original post isn't real production code. &nbsp;But if I just look at that example the only thing I would mock is `do_some_stuff` because it's a collaborator.<br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<p class="MsoNormal">-- <br>
David<br>
blog: <a href="http://www.traceback.org" target="_blank">http://www.traceback.org</a><br>
twitter: <a href="http://twitter.com/dstanek" target="_blank">http://twitter.com/dstanek</a><o:p></o:p></p>
<div>
<p class="MsoNormal">www: <a href="http://dstanek.com" target="_blank">http://dstanek.com</a><o:p></o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>