Skip to main content

Simple extension to have parametrized unit tests.

Project description

This package allows to create parametrized unit-tests that work with the standard unittest package. A parametrized test case is automatically converted to multiple test cases. Since they are TestCase subclasses, they work with other test suites that recognize TestCases.

Examples:

import unittest
import paramunittest

@paramunittest.parametrized(
    ('1', '2'),
    #(4, 3),
    ('2', '3'),
    (('4', ), {'b': '5'}),
    ((), {'a': 5, 'b': 6}),
    {'a': 5, 'b': 6},
)
class TestFoo(paramunittest.ParametrizedTestCase):
    def setParameters(self, a, b):
        self.a = a
        self.b = b

    def testLess(self):
        self.assertLess(self.a, self.b)

@paramunittest.parametrized(
    ('1', '2'),
    #(4, 3),
    ('2', '3'),
    (('4', ), {'b': '5'}),
    ((), {'a': 5, 'b': 6}),
    {'a': 5, 'b': 6},
)
class TestBar(unittest.TestCase):
    def setParameters(self, a, b):
        self.a = a
        self.b = b

    def testLess(self):
        self.assertLess(self.a, self.b)

Project details


Download files

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

Source Distributions

ParamUnittest-0.2.zip (4.6 kB view hashes)

Uploaded Source

ParamUnittest-0.2.tar.gz (2.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page