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

后端 未结 25 2139
面向向阳花
面向向阳花 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:39

    The metaclass-based answers still work in Python3, but instead of the __metaclass__ attribute one has to use the metaclass parameter, as in:

    class ExampleTestCase(TestCase,metaclass=DocTestMeta):
        pass
    

提交回复
热议问题