class Config(list):
def __init__(self, *args):
super().__init__(*args)
[
{"id": 1, "name": "1"},
{"id": 2, "name": "2"}
]
demo_data = [
{"id": 1, "name": "1"},
{"id": 2, "name": "2"}
]
class DemoData(Config):
def __init__(self):
super().__init__(*demo_data)
class TestDemoPyTest:
@user1ize('demo', DemoData())
def test_id(self, demo):
assert demo['id'] > 0, "id不大于0"
@ddt
class TestDemoUnitTest(unittest.TestCase):
@data(*DemoData())
def test_id(self, demo):
self.assertGreater(demo['id'], 0, "id不大于0")
简易的架构搭建这就完成了,希望对大家有所帮助。