Some Django unit tests fail...

10 views
Skip to first unread message

Peter Melvyn

unread,
Jun 19, 2008, 9:27:35 AM6/19/08
to django...@googlegroups.com
Hi all,

I wanted to make sure that all unit tests will pass after #3030 fix
and run Django unit tests on trunk updated to r7703 on Windows, Python
2.4 and MySQL 5.0.37.

But I found that some test failes:

1. If I've run all tests, I get error:

Traceback (most recent call last):
File "C:\Python24\Lib\site-packages\django-trunk\tests\runtests.py",
line 183, in ?
django_tests(int(options.verbosity), options.interactive, args)
File "C:\Python24\Lib\site-packages\django-trunk\tests\runtests.py",
line 153, in django_tests
failures = run_tests(test_labels, verbosity=verbosity,
interactive=interactive, extra_tests=extra_tests)
File "C:\Python24\Lib\site-packages\django-trunk\django\test\simple.py",
line 136, in run_tests
suite.addTest(build_suite(app))
File "C:\Python24\Lib\site-packages\django-trunk\django\test\simple.py",
line 59, in build_suite
test_module = get_tests(app_module)
File "C:\Python24\Lib\site-packages\django-trunk\django\test\simple.py",
line 17, in get_tests
test_module = __import__('.'.join(app_path + [TEST_MODULE]), {},
{}, TEST_MODULE)
File "C:\Python24\Lib\site-packages\django-trunk\tests\regressiontests\templates\tests.py",
line 23, in ?
from loaders import *
File "C:\Python24\Lib\site-packages\django-trunk\tests\regressiontests\templates\loaders.py",
line 13, in ?
import pkg_resources
ImportError: No module named pkg_resources


2. If I've run single tests, I get error in some particular tests as well, e.g.

FAIL: Doctest: modeltests.basic.models.__test__.API_TESTS
----------------------------------------------------------------------
...
Failed example:
Article.objects.get(pk=a.id).headline
Expected:
u'\u6797\u539f \u3081\u3050\u307f'
Got:
u'Article 12'

###

FAIL: Doctest: modeltests.custom_pk.models.__test__.API_TESTS
----------------------------------------------------------------------

File "C:\Python24\Lib\site-packages\django-trunk\tests\modeltests\custom_pk\models.py",
line ?, in modeltests.custom_pk.models.__test__.API_TESTS
Failed example:
emp.save()
Exception raised:
Traceback (most recent call last):
File "C:\Python24\Lib\site-packages\django-trunk\django\test\_doctest.py",
line 1267, in __run
compileflags, 1) in test.globs
File "<doctest
modeltests.custom_pk.models.__test__.API_TESTS[34]>", line 1, in ?
emp.save()
File "C:\Python24\Lib\site-packages\django-trunk\django\db\models\base.py",
line 272, in save
self.save_base()
File "C:\Python24\Lib\site-packages\django-trunk\django\db\models\base.py",
line 313, in save_base
if manager.filter(pk=pk_val).extra(select={'a':
1}).values('a').order_by():
File "C:\Python24\Lib\site-packages\django-trunk\django\db\models\query.py",
line 84, in __nonzero__
iter(self).next()
File "C:\Python24\Lib\site-packages\django-trunk\django\db\models\query.py",
line 78, in _result_iter
self._fill_cache()
File "C:\Python24\Lib\site-packages\django-trunk\django\db\models\query.py",
line 494, in _fill_cache
self._result_cache.append(self._iter.next())
File "C:\Python24\Lib\site-packages\django-trunk\django\db\models\query.py",
line 520, in iterator
for row in self.query.results_iter():
File "C:\Python24\Lib\site-packages\django-trunk\django\db\models\sql\query.py",
line 200, in results_iter
for rows in self.execute_sql(MULTI):
File "C:\Python24\Lib\site-packages\django-trunk\django\db\models\sql\query.py",
line 1474, in execute_sql
cursor.execute(sql, params)
File "C:\Python24\Lib\site-packages\MySQLdb\cursors.py", line
166, in execute
self.errorhandler(self, exc, value)
File "C:\Python24\Lib\site-packages\MySQLdb\connections.py",
line 35, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1267, "Illegal mix of collations
(latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for
operation '='")

etc...

###

Is there anything I've missed that Django unit tests do not pass on my
installation?


Thx, Peter

Russell Keith-Magee

unread,
Jun 19, 2008, 9:38:52 AM6/19/08
to django...@googlegroups.com
On Thu, Jun 19, 2008 at 9:27 PM, Peter Melvyn <peter....@gmail.com> wrote:
>
> Hi all,
>
> I wanted to make sure that all unit tests will pass after #3030 fix
> and run Django unit tests on trunk updated to r7703 on Windows, Python
> 2.4 and MySQL 5.0.37.

I'm not seeing any failures at the moment; the buildbot:

http://buildbot.djangoproject.com/

concurs (for trunk, anyway).

> Is there anything I've missed that Django unit tests do not pass on my
> installation?

The only obvious thing I can glean from your stack traces is a
possible language problem - the last stack trace is complaining of a
collation mix, which suggests that your MySQL install isn't using utf8
all the time.

Yours
Russ Magee %-)

Ramiro Morales

unread,
Jun 19, 2008, 10:08:48 AM6/19/08
to django...@googlegroups.com

AFAICT the failing test is the one trying to execise the Python egg
template loader.

I've found this same problem last week both on a Linux system and on a
Windows one.
The common factor was they were systems where the 'stack' has had just
been installed
Python 2.4 and Python 2.5 respectively). Installing the right
setuptools version solved the
problems.

Maybe a note about this dependency of that particular Django test
suite component could
be added to the "Unit tests" section of the "Contributing to Django" document?.

Regards,

--
Ramiro Morales

Russell Keith-Magee

unread,
Jun 19, 2008, 10:20:15 AM6/19/08
to django...@googlegroups.com
On Thu, Jun 19, 2008 at 10:08 PM, Ramiro Morales <cra...@gmail.com> wrote:
>
> I've found this same problem last week both on a Linux system and on a
> Windows one.
> The common factor was they were systems where the 'stack' has had just
> been installed
> Python 2.4 and Python 2.5 respectively). Installing the right
> setuptools version solved the
> problems.
>
> Maybe a note about this dependency of that particular Django test
> suite component could
> be added to the "Unit tests" section of the "Contributing to Django" document?.

I'm happy to add the note. Open a ticket with some draft text, bump it
to ready-for-checkin and I'll commit it when I get a chance.

Yours,
Russ Magee %-)

Peter Melvyn

unread,
Jun 19, 2008, 1:07:07 PM6/19/08
to django...@googlegroups.com
On 6/19/08, Russell Keith-Magee <freakb...@gmail.com> wrote:

> The only obvious thing I can glean from your stack traces is a
> possible language problem - the last stack trace is complaining of a
> collation mix, which suggests that your MySQL install isn't using utf8
> all the time.

Yes, it is the intention. If Django requires test database with
charset UTF8, IMHO it should create it using related clause. as well
as proper engine should be choosen if we care about reference
integrity, e.g.

SET storage_engine=InnoDB;
CREATE DATABASE xxx
DEFAULT CHARACTER SET utf8
COLLATE utf8_xxx_ci;


Should I create a ticket ;-)

Peter

Russell Keith-Magee

unread,
Jun 19, 2008, 7:47:34 PM6/19/08
to django...@googlegroups.com

I won't ever say no to a ticket. Make a proposal, and we will see if
it floats :-)

Yours
Russ Magee %-)

Ramiro Morales

unread,
Jun 20, 2008, 12:29:09 PM6/20/08
to django...@googlegroups.com

Done on #7513

Regards,

--
Ramiro Morales

Russell Keith-Magee

unread,
Jun 21, 2008, 1:23:49 AM6/21/08
to django...@googlegroups.com

Fixed in [7718].

Thanks for the original draft - you'll note that my text is slightly
different to yours. It occurred to me that there are actually a couple
of other dependencies to the test system, but they are silent failures
- the tests are skipped if the dependent libraries are not found. If
anyone with a 'clean' system wants to work on a patch to do the same
for the egg loader test (including an update to the contributing.txt
documentation I just added), I'll commit it.

Yours,
Russ Magee %-)

Peter Melvyn

unread,
Jun 24, 2008, 3:16:06 PM6/24/08
to django...@googlegroups.com
> On Fri, Jun 20, 2008 at 1:07 AM, Peter Melvyn <peter....@gmail.com> wrote:

> > Yes, it is the intention. If Django requires test database with
> > charset UTF8, IMHO it should create it using related clause. as well
> > as proper engine should be choosen if we care about reference
> > integrity, e.g.
> >
> > SET storage_engine=InnoDB;
> > CREATE DATABASE xxx
> > DEFAULT CHARACTER SET utf8
> > COLLATE utf8_xxx_ci;

I found that Django is awared for this already: in django.test.utils
is the function get_mysql_create_suffix() which reads values
TEST_DATABASE_CHARSET and COLLATION from settings...


> I won't ever say no to a ticket. Make a proposal, and we will see if
> it floats :-)

I've added a note highlighting this in paragraph describing django
tests in contribution chapter and created ticket #7534

Peter

Reply all
Reply to author
Forward
0 new messages