Nose generate dynamically test with decorator
<p>I have dynamic amount of test so i want use for loop
I'd try something like:</p>

<pre><code>from nose.tools import istest, nottest
from nose.tools import eq_
import nose
nose.run()
@istest
def test_1():
    for i in range(100):
        @istest
        def test_1_1():
            eq_(randint(1,1),1)



---------------------
Ran 1 test in 0.001s

OK
</code></pre>

<p>But nose display it like only one test. How can i improve it to 100 tests?
Thanks in advance.</p>

<p>For data-driven tests in nose, check out <a href="https://pypi.python.org/pypi/nose-parameterized/" rel="nofollow"><code>nose_parameterized</code></a>.</p>

<p>Example usage:</p>

<pre><code>from nose_parameterized import parameterized

@parameterized.expand([(1, 1, 2), (2, 2, 4)])
def test_add(self, a, b, sum):
    self.assertEqual(sum, a + b)
</code></pre>

<p>Here, two tests will be generated by the runner.  It tests <code>1+1==2</code> and <code>2+2==4</code>.  The decorator is also compatible with other test runners such as <code>unittest</code>.  </p>

python python-2.7 nose