Py学习  »  b0lle  »  全部回复
回复总数  1
4 年前
回复了 b0lle 创建的主题 » Python:用具体的实现细节测试抽象类

您可以简单地使用多重继承:

# test_animals.py
import unittest

from animals import Animal


class TestAnimal(unittest.TestCase, Animal):

    def description(self) -> str:
        return "Unittest"

    def test_zoo_str(self) -> None:
        assert self.zoo_str() == "UnittestGet more info at zoo.com!"