django - 删除模型妈妈实例
问题描述
我正在使用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
实例。有什么办法可以做到这一点?谢谢
解决方案
推荐阅读
- angular - 无法使用@input 将数据传递给 ng-bootstrap
- c# - 为单选按钮提供必填字段验证器
- java - 解决gradle中的循环依赖
- javascript - jQuery UI 自动完成突出显示多个输入:对大写字母不起作用?
- reverse-proxy - OPLON LBL ADC 重写 http 正文以在 xml 内容之前清除值
- mongodb - Mongodb - 聚合函数嵌套ob
- java - @Transactional 的默认传播行为
- python - 寻找内置列表函数的 Python 代码
- reactjs - 如何使用 react-redux useSelector 和 useDispatch 检查道具类型
- c - 如何移动 gcno 文件以及如何使用 GCOV_PREFIX 移动 gcda 文件?