How do you generate dynamic (parameterized) unit tests in python?

后端 未结 25 2166
面向向阳花
面向向阳花 2020-11-22 07:09

I have some kind of test data and want to create a unit test for each item. My first idea was to do it like this:

import unittest

l = [[\"foo\", \"a\", \"a\         


        
25条回答
  •  情话喂你
    2020-11-22 07:24

    You would benefit from trying the TestScenarios library.

    testscenarios provides clean dependency injection for python unittest style tests. This can be used for interface testing (testing many implementations via a single test suite) or for classic dependency injection (provide tests with dependencies externally to the test code itself, allowing easy testing in different situations).

提交回复
热议问题