尝试在我们的django项目上设置我们的系统,以利用django的测试框架。但是,当我尝试运行python manage.py test
时,我会在下面解释各种错误。
我们正在开发一个django环境,我们使用reset.bat批处理文件来重启我们的开发服务器并从我们的fixture中加载“干净”的数据。除了处理我们的本地环境外,后台文件还会执行以下操作:
Drops and Creates the MySQL Database "testsqldb"
drop database testsqldb;
create database testsqldb;
Syncs the database with the models (ignoring anything with South migrations)
python manage.py syncdb --noinput
Runs the migrations
python manage.py migrate --no-initial-data
Loads the fixtures
python manage.py loaddata <fixture1> <fixture2> <fixture3> ...
当我尝试将InnoDB Engine设置为默认运行python manage.py test
时,我得到:
! Error found during real run of migration! Aborting.
! Since you have a database that does not support running
! schema-altering statements in transactions, we have had
! to leave it in an interim state between migrations.
! You *might* be able to recover with:
撤消创建的表的SQL命令显示在“此处”。
! The South developers regret this has happened, and would
! like to gently persuade you to consider a slightly
! easier-to-deal-with DBMS.
! NOTE: The error which caused the migration to fail is further up.
当我尝试使用MyISAM运行python manage.py test
时,我得到的错误是我们假装在系统运行时创建的系统表。
有关如何让测试运行的任何想法或想法都将受到赞赏。
答案 0 :(得分:1)
当我尝试使用MyISAM运行python manage.py测试时,我得到的错误是我们在系统上伪造的一个表,它应该在系统运行时创建。
如果您为此创建了一个模型,那么如果将Meta选项标记为managed=False
,这可能会有所帮助。然后django不会涉及创建它。