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


Release history Release notifications

This version
History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
test-tools-0.0.3.tar.gz (4.4 kB) Copy SHA256 hash SHA256 Source None May 5, 2015

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page