Django-admin.py sqlflush error during tests

I have a test suite in my Django application that passed before, but at some point in the evolution of the software, I started getting this message when I run the tests:

Error: The test_totomanager_demo database could not be reset. Possible reasons:
* The database is not running or is not configured correctly.
* At least one of the expected database tables does not exist.
* SQL was invalid.
Hint. Look at the output of "django-admin.py sqlflush". That the SQL of this command failed to start.
Full error: (1105, "MyISAM table" video_videoinstallation "is used (most likely in the MERGE table). Try FLUSH TABLES.")

The database is MySQL.

The exact test in which this error occurs is unpredictable. This is not the first time this happens, but after one or two tries to pass it, this time I can not complete the tests.

Any hint on how to avoid this?

+6
django mysql myisam
source share
3 answers

Probably because your table type is MyISAM, which blocks the whole table, if you do not need the “FULL TEXT SEARCH” in this table, you should make it innodb table.

I don't know how django tests run, but one possible solution is to run one test at a time, instead of running them all at once, to avoid testing when the table is locked.

+1
source share

I had the problem itself and I understood, because I had not yet created a migration to change the model.

Try:

./manage.py schemamigration <your_app_name> --auto 

I have southern migrations installed in this virtualenv, so this is probably a requirement if you don't want to write the migration yourself.

0
source share

Use testCase python class instead of Django.

 Replace from django.test import TestCase class TestChrono(TestCase): with import unittest class TestChrono(unittest.TestCase): 

This is a workaround, but, of course, it will not affect your test case if you are not using the devices. Django Testcase is trying to play with transaction management, so you get this error.

0
source share

All Articles