Skip to main content

Run a test case multiple times with different data

Project description

datadriven

datadriven allows you to run a test case multiple times with different data. It was designed to work with unittest.TestCase test methods, any test runner (nose, nose2, unittest, unittest2 and pytest), in Python 2.7 or 3.7+.

Usage

import datadriven

class SomeTestCase(unittest.TestCase):

    @datadriven.datadriven(
        caseA=datadriven.Args(first="foo"),
        caseB=datadriven.Args("hello", second="world"),
    )
    def test_method(self, first, second=None):
        ...

This is the equivalent of writing:

import datadriven

class SomeTestCase(unittest.TestCase):

    def test_method(self, first, second=None):
        ...

    def test_method_caseA(self):
        self.test_method("foo")

    def test_method_caseB(self):
        self.test_method("hello", "world")

The only difference is that when wrapped with @datadriven, the test test_method won't be really executed.

License

Apache-2.0 License

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

datadriven-1.0.0.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distributions

datadriven-1.0.0-py3-none-any.whl (7.1 kB view hashes)

Uploaded Python 3

datadriven-1.0.0-py2-none-any.whl (7.0 kB view hashes)

Uploaded Python 2

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