Django单元测试keepdb参数
在编写单元测试时,每次重新创建MySQL数据库表都花费很长时间,于是在表结果不变的情况下,想使用keepdb参数,即执行python manage.py test --keepdb, 会报如下错误
1 | Using existing test database for alias 'default'... |
查找错误来源,在django.db.backends.mysql.creation.py里的_execute_create_test_db函数中,
将
1 | cursor.execute(''' |
改成
1 | cursor.execute(''' |
后,问题得到解决。

