Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#8215 closed (wontfix)

Tests raise UnicodeDecodeError instead of showing the test that failed

Reported by: Owned by: nobody
Component: Testing framework Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This problem bit me while trying to adjust the regressionstests for #6873. Instead of reporting that tests/regressiontests/forms/widgets.py, Line 641 failed it just threw this error:

vm3:/home/dev/django-trunk/tests# ./runtests.py --settings settings forms
======================================================================
ERROR: Doctest: regressiontests.forms.tests.__test__.widgets_tests
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/django/test/_doctest.py", line 2176, in runTest
    failures, tries = runner.run(
  File "/usr/lib/python2.4/site-packages/django/test/_doctest.py", line 1405, in run
    return self.__run(test, compileflags, out)
  File "/usr/lib/python2.4/site-packages/django/test/_doctest.py", line 1318, in __run
    self.report_failure(out, test, example, got)
  File "/usr/lib/python2.4/site-packages/django/test/_doctest.py", line 1185, in report_failure
    out(self._failure_header(test, example) +
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 240: ordinal not in range(128)

Maybe all these Unicode strings in the tests without a small u in front need changing?

I know the information in this ticket is not really exhaustive. Just let me know what would help :)

Change History (3)

comment:1 by Malcolm Tredinnick, 16 years ago

Resolution: wontfix
Status: newclosed

This is a known problem with Python's standard doctest.py file, which we use in Django. We don't modify that file so that it's easy to sync with upstream now and again. One day we might really go to town there to change things, but it's not something we're rushing to do.

For now, this is wontfix, just because it's a problem right across the board, not just with Django. Unfortunately, if you see a test that fails like this, the solution is to change the test to print out UTF-8 data (or similar) just whilst you are debugging. Annoying... absolutely! But it happens relatively rarely (since tests pass a lot more than they fail) and it's easy enough to work around.

(By the way, if you're wondering: it's got nothing to do with marking the strings as unicode strings, since they're already wrapped in a larger string (the docstring for the test).)

comment:2 by , 16 years ago

Thx for the explanation Malcolm.

Unfortunately, if you see a test that fails like this, the solution is to change the test to print out UTF-8 data (or similar) just whilst you are debugging.

You mean getting debug print to track where it's breaking? I wanted to do just that but had no idea how ... "print" doesn't work. Could you post a pointer so the next person running into this can look it up?

comment:3 by (none), 16 years ago

milestone: post-1.0

Milestone post-1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top