首页 > 解决方案 > 删除模型妈妈实例

问题描述

我正在使用model-mommy来生成测试数据,如下所示

class AuthorDetailViewTests(TestCase):

    def setUp(self):
        # set bio manually to avoid error being thrown by template tag markdown_format
        self.author = mommy.make('author.Author', bio='Some bio text')

    def tearDown(self):
        self.author.delete()

setUp()方法工作正常。问题是该tearDown()方法实际上并没有删除创建的author实例。有什么办法可以做到这一点?谢谢

标签: djangomodel-mommy

解决方案


推荐阅读