【问题标题】:How to automatically destroy django test database如何自动销毁django测试数据库
【发布时间】:2012-08-20 05:36:03
【问题描述】:

我目前正在尝试使用 Hudson CI 自动化 Django 测试,并且正在努力寻找一个选项,如果它已经存在,它将自动销毁测试数据库(通常它会要求确认以销毁它,这显然是自动测试无法提供)。

任何建议将不胜感激!

干杯, 回复

【问题讨论】:

  • 啊。做到了!这到底是在哪里记录的?
  • 在答案中回答了这个问题,这样您就可以关闭问题(这将为那些花时间潜伏在 SO 寻找未解决问题的人节省时间)

标签: python database django testing hudson


【解决方案1】:

使用 --help 查看测试命令的文档:

>>> ./manage.py test --help   
Usage: ./manage.py test [options] [appname ...]

Runs the test suite for the specified applications, or the entire site if no apps are specified.

[...]

--noinput             Tells Django to NOT prompt the user for input of any
                      kind.

并使用--noinput 默认销毁测试数据库;)

【讨论】:

  • ...你知道,我做了什么?我每次都手动修补 Django,将“autoclobber”设置为 True。谢谢。这应该记录在 Django 文档的某个地方,如果还没有的话。
  • "这应该记录在某处..." -- 似乎现在记录在案,但仅在此处。
  • 另外,--noinput 与 testserver 命令一起工作的事实显然没有记录,例如manage.py testserver --noinput my_fixture.json
  • 现在记录在案(此时在开发文档中)。 docs.djangoproject.com/en/dev/topics/testing/overview
猜你喜欢
  • 2014-12-15
  • 1970-01-01
  • 2019-03-26
  • 2023-03-28
  • 2013-02-14
  • 2017-12-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多