Opened 16 years ago
Closed 16 years ago
#8780 closed (invalid)
Various unicode unit tests may fail on MySQL, since test database may be created without utf-8 character set
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Keywords: | ||
Cc: | richard.davies@… | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The MySQL installation notes state that the database character set should be utf-8, specified by either "CREATE DATABASE <dbname> CHARACTER SET utf8;" or a database-wide default "mysqld -C utf8" or "default-character-set = utf8"
runtests.py creates a new test database, but does not force the character set to utf8 when it does so.
This means that users configured with a database-wide default of utf8 will find that runtests.py works fine.
However, users who only set this for their working Django database, may find that the new test database has the wrong character set, in which case they will see several tests fail (one example below):
$ ./runtests.py --settings=SETT_mysql basic ====================================================================== FAIL: Doctest: modeltests.basic.models.__test__.API_TESTS ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/elastic/django-dev/trunk3/django/test/_doctest.py", line 2180, in runTest raise self.failureException(self.format_failure(new.getvalue())) AssertionError: Failed doctest test for modeltests.basic.models.__test__.API_TESTS File "/home/elastic/django-dev/trunk3/tests/modeltests/basic/models.py", line unknown line number, in API_TESTS ---------------------------------------------------------------------- File "/home/elastic/django-dev/trunk3/tests/modeltests/basic/models.py", line ?, in modeltests.basic.models.__test__.API_TESTS Failed example: Article.objects.get(pk=a.id).headline Expected: u'\u6797\u539f \u3081\u3050\u307f' Got: u'?? ???' ---------------------------------------------------------------------- Ran 1 test in 0.149s FAILED (failures=1)
The answer is probably for the test framework to force a complete "CREATE DATABASE <dbname> CHARACTER SET utf8;" when it creates the test database when run with the mysql backend.
Change History (2)
comment:1 by , 16 years ago
comment:2 by , 16 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
This is documented and expected. We don't/can't make too many assumptions about the target environment, so we provide a setting if changes are required. The same test framework is used for testing non-core stuff, so we can't mess with the character encoding too much, since people should be testing their apps with the same encoding and collation as in their production settings.
You need to specify
TEST_DATABASE_CHARSET
and/orTEST_DATABASE_COLLATION
as described here: http://docs.djangoproject.com/en/dev/topics/testing/#the-test-database