修改 settings.py
# 重写一个testRunner,忽略新建删除数据库
class NoDbTestRunner(DiscoverRunner):
""" A test runner to test without database creation """
def setup_databases(self, **kwargs):
""" Override the database creation defined in parent class """
pass
def teardown_databases(self, old_config, **kwargs):
""" Override the database teardown defined in parent class """
pass
# 在settings中给TEST_RUNNER赋值新的testRunner
TEST_RUNNER = 'testDjango.settings.NoDbTestRunner'
网友评论