<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
On 06/08/2010 03:20, Brian Curtin wrote:
<blockquote
 cite="mid:AANLkTik8Dea_=E6DkaC10unit4x+jH6T3kKsBoK3p9EP@mail.gmail.com"
 type="cite">
  <div class="gmail_quote">On Thu, Aug 5, 2010 at 20:56, Michael Foord <span
 dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:fuzzyman@voidspace.org.uk">fuzzyman@voidspace.org.uk</a>&gt;</span>
wrote:<br>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
    <div class="im">On 06/08/2010 02:49, Jesse Noller wrote:<br>
    <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Thu, Aug 5, 2010 at 9:31 PM, Michael Foord&lt;<a
 moz-do-not-send="true" href="mailto:fuzzyman@voidspace.org.uk"
 target="_blank">fuzzyman@voidspace.org.uk</a>&gt; &nbsp;wrote:<br>
&nbsp; <br>
      <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 06/08/2010 02:23, Jesse Noller wrote:<br>
&nbsp; &nbsp; <br>
        <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
[snip...]<br>
ps: If nose2/unittest2 could find it in it's shiny new innocent heart<br>
to say, have support for test generators; I'd die happy.<br>
          <br>
&nbsp; &nbsp; &nbsp; <br>
        </blockquote>
Well there's another discussion :-)<br>
        <br>
It would be very simple to support parameterized tests (of some form),
where<br>
the number of tests can be known at test load time. Supporting
generative<br>
tests - where the tests are generated at *test run time* is uglier.<br>
        <br>
Would parameterized tests, where the tests are all generated at test
load<br>
time, suffice or do you have a use case for generative tests where the
tests<br>
have to be generated whilst the tests are running and not when the
tests are<br>
loaded?<br>
        <br>
Michael<br>
&nbsp; &nbsp; <br>
      </blockquote>
For me? To be honest, 98% of my (and the people around me) use cases<br>
are the parameterized case - the test generator syntax is just pure<br>
awesome (Ok, so I really like it) tests generated at run time tends to<br>
rub most people wrong :)<br>
&nbsp; <br>
    </blockquote>
    <br>
    </div>
Ok. Good syntax is generally a good thing, and there is no reason why a
generator couldn't be called at test load time to generate the tests -
perhaps in conjunction with a decorator so we don't have to do horrible
introspection to determine if something is a test generator or not.<br>
    <br>
Could you give me an example usage please, so I can think about how to
support it (probably initially as a plugin).<br>
    <br>
All the best,<br>
    <br>
Michael</blockquote>
  <div><br>
  </div>
  <div>I've wanted to do something like this in the past...</div>
  <div><br>
  </div>
  <div>@unittest.params((1, 1), (2, 0), &nbsp;(1, 2))</div>
  <div>def test_addition(self, x, y):</div>
  <div>&nbsp;&nbsp; &nbsp;self.assertEqual(x + y, 2)</div>
  <div><br>
  </div>
  <div>...resulting in two passes, one fail.</div>
  <div><br>
  </div>
  <div>I think I already mentioned this or something like it on the
Roundup issue for this topic. I have part of a patch around somewhere,
but it's far from complete.</div>
  </div>
</blockquote>
Ok, I've just added this to the moduleloading plugin tool. Pulling it
over into unittest itself would be trivially easy. Whether we should
add parameterized or generated tests (or even both?) to core unittest -
or maybe just pull in the moduleloading plugin when plugins are merged
into unittest - is still an open question.<br>
<br>
Michael<br>
<br>
<pre class="moz-signature" cols="72">-- 
<a class="moz-txt-link-freetext" href="http://www.ironpythoninaction.com/">http://www.ironpythoninaction.com/</a>
<a class="moz-txt-link-freetext" href="http://www.voidspace.org.uk/blog">http://www.voidspace.org.uk/blog</a>

READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (&#8221;BOGUS AGREEMENTS&#8221;) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.

</pre>
</body>
</html>