<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    On 8/13/14 4:15 PM, Marcin Tustin wrote:<br>
    <blockquote
      cite="mid:00BB772A2997564C8A33493B6E389CDA736925@NHPDAG002.dt.inc"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <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]-->
      <div class="WordSection1">
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Yes:
            the reason is that I&#8217;m not writing an integration test, I&#8217;m
            writing a test to test this specific method. We need unit
            tests to test our individual units, and integration tests to
            test them together. It&#8217;s not wise to rely only on
            integration tests (nor only on unit tests).</span></p>
      </div>
    </blockquote>
    <br>
    I say let the test call super(), and call it a unit test.&nbsp; These
    terms can't be taken too literally.&nbsp; Other than it being "the wrong
    kind" of test, what actual bad thing will happen if you call super()
    in your unit test?<br>
    <br>
    This seems like a lot of effort to subvert Python's class
    machinery.&nbsp; You'll end up with a mess, and probably more follow-on
    problems than you solve.<br>
    <br>
    Probably the best approach is to refactor your code so that its more
    easily tested: if you are interested in what foofunc does without
    consideration of the base class, then create a function that doesn't
    call the base class.&nbsp; Test that function.&nbsp; Then you can call that
    function from another which does call the base class.<br>
    <br>
    --Ned.<br>
    <blockquote
      cite="mid:00BB772A2997564C8A33493B6E389CDA736925@NHPDAG002.dt.inc"
      type="cite">
      <div class="WordSection1">
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><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">I
            actually do share the concern about over mocking (it&#8217;s easy
            to mock so much that you test nothing), but it&#8217;s important
            not to throw the baby out with the bathwater. Integration
            tests by their nature lack granularity to pinpoint problems
            (and yes, I realize it&#8217;s possible and desirable to set up
            integration tests so that do point to where a detected
            problem originates, but it&#8217;s still not a substitute for
            appropriate unit testing).<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 [<a class="moz-txt-link-freetext" href="mailto:dstanek@dstanek.com">mailto:dstanek@dstanek.com</a>]
            <br>
            <b>Sent:</b> Wednesday, August 13, 2014 2:35 PM<br>
            <b>To:</b> Marcin Tustin<br>
            <b>Cc:</b> <a class="moz-txt-link-abbreviated" href="mailto:testing-in-python@lists.idyll.org">testing-in-python@lists.idyll.org</a><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 2:00 PM,
                Marcin Tustin &lt;<a moz-do-not-send="true"
                  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">Hi
                    All,<o:p></o:p></p>
                  <p class="MsoNormal"
                    style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">&nbsp;<o:p></o:p></p>
                  <p class="MsoNormal"
                    style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I&#8217;ve
                    come across a method which I needed to add a unit
                    test for, which calls super, e.g.<o:p></o:p></p>
                  <p class="MsoNormal"
                    style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><o:p>&nbsp;</o:p></p>
                </div>
              </div>
            </div>
            <p class="MsoNormal"><br>
              Is there any reason you can't call the parent's super? &nbsp;In
              my view of testing you want to create an object, feed it
              input, and then check the output/side effect. I would stay
              away from mocking internals like this.<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 moz-do-not-send="true"
                href="http://www.traceback.org" target="_blank">http://www.traceback.org</a><br>
              twitter: <a moz-do-not-send="true"
                href="http://twitter.com/dstanek" target="_blank">http://twitter.com/dstanek</a><o:p></o:p></p>
            <div>
              <p class="MsoNormal">www: <a moz-do-not-send="true"
                  href="http://dstanek.com" target="_blank">http://dstanek.com</a><o:p></o:p></p>
            </div>
          </div>
        </div>
      </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>