Skip to main content

Tools for unit testing: data_provider and FixtureManager

Project description

Test files in project

/tests
    __init__.py
    /pkg1
        /fixtures
            foo1.json
            foo2.json
        __init__.py
        test1.py
    /pkg2
        /fixtures
            bar1.json
            bar2.json
        __init__.py
        test2.py

Content of “tests/pkg1/fixtures/foo1.json”:

{
    "blah1": [
        ["foo"],
        ["bar"],
        [1],
        [2],
        [true],
        [null]
    ],
    "blah2": [
        [-1234, 0],
        [3456, -2.345],
        [1, 1],
        [99999, false],
        [11, 789],
        [null, null]
    ]
}

Content of “tests/pkg1/test1”:

from unittest import TestCase

from test_tools import data_provider, FixtureManager

fx_man1 = FixtureManager()
fx_man1.load(fixture_file='foo1')

fx_man2 = FixtureManager()
fx_man2.load(fixture_file='foo2')


class MyTestCase(TestCase):
    @data_provider(fx_man1['blah1'])
    def test_my_cool_feature(self, param1):
        # some code
        pass

    @data_provider(fx_man1['blah2'])
    def test_my_cool_feature(self, param1, param2):
        # some code
        pass

    @data_provider(fx_man2['blah3'])
    def test_my_cool_feature(self, param):
        # some code
        pass

Project details


Download files

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

Files for test-tools, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size test-tools-0.0.3.tar.gz (4.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page