Nathan Tregillus
Nathan Tregillus

Reputation: 6334

Python unit tests: TestCaseSource

I am new to python development, specifically Django pipeline. I am used to nunit testing framework where I have tools such as the TestCaseData class.

we are currently using the nose framework with the django.test modules.

heres my question: is there a module or some component that does the same thing for python/django code?

Upvotes: 0

Views: 159

Answers (1)

Nathan Tregillus
Nathan Tregillus

Reputation: 6334

after researching a fair bit, I decided to use nose-parameterized. it works in both functional tests, and class based tests, and I can provide it a static method to supply test cases that are programmatically generated like the following:

def test_case_source():
    parameters = []
    for i in range(0,10):
        parameters.append(('test{0}'.format(i), i))
    return parameters

class TestTestCaseSource(TestCase):
    @parameterized.expand(test_case_source())
    def test_my_fake_test(self, test_name, param):
        self.assertEquals(param, param)

Upvotes: 2

Related Questions