Skip to main content

Nose decorator for parameterized testing

Project description

Nose. It’s got test generators. But they kind of suck, because:

  • They often require a second function

  • They make it difficult to separate the data from the test

  • They don’t work with subclases of unittest.TestCase

But nose-parameterized fixes that:

$ cat
from import assert_equal
from nose_parameterized import parameterized

import unittest
import math

    (2, 2, 4),
    (2, 3, 8),
    (1, 9, 1),
    (0, 9, 0),
def test_pow(base, exponent, expected):
    assert_equal(math.pow(base, exponent), expected)

class TestMathUnitTest(unittest.TestCase):
        (-1.5, -2.0),
        (1.0, 1.0),
        (1.6, 1),
    def test_floor(self, input, expected):
        assert_equal(math.floor(input), expected)
$ nosetests -v
test_math.test_pow(2, 2, 4) ... ok
test_math.test_pow(2, 3, 8) ... ok
test_math.test_pow(1, 9, 1) ... ok
test_math.test_pow(0, 9, 0) ... ok
test_floor_0 (test_math.TestMathUnitTest) ... ok
test_floor_1 (test_math.TestMathUnitTest) ... ok
test_floor_2 (test_math.TestMathUnitTest) ... ok

Ran 7 tests in 0.002s


Now with Python 3 support!

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nose-parameterized-0.2.tar.gz (8.0 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page