Opened 13 years ago

Closed 12 years ago

#17116 closed Bug (fixed)

Changing the default encoding breaks test_broken_unicode (regressiontests.model_regress.tests.ModelTests)

Reported by: Raphaël Hertzog <hertzog@…> Owned by: nobody
Component: Testing framework Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This bug has been reported in the Debian bug tracking system: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=646634

If you add the lines below to /etc/python2.7/sitecustomize.py:

import sys
sys.setdefaultencoding('utf8')

Then you get this test failure:

FAIL: test_broken_unicode (regressiontests.model_regress.tests.ModelTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/python-django-1.3.1/tests/regressiontests/model_regress/tests.py", line 146, in
test_broken_unicode
    self.assertEqual(repr(b), "<BrokenUnicodeMethod: [Bad Unicode data]>")
AssertionError: '<BrokenUnicodeMethod: N\xc3\xa1zov: Jerry>' != '<BrokenUnicodeMethod: [Bad
Unicode data]>'

I know it's not a good idea to change the default encoding but maybe this test could be skipped if sys.getdefaultencoding() doesn't return ascii.

Attachments (1)

17116.diff (1.1 KB ) - added by Claude Paroz 13 years ago.
Skip if default encoding is not ascii

Download all attachments as: .zip

Change History (3)

by Claude Paroz, 13 years ago

Attachment: 17116.diff added

Skip if default encoding is not ascii

comment:1 by Claude Paroz, 13 years ago

Has patch: set
Triage Stage: UnreviewedAccepted

comment:2 by Claude Paroz, 12 years ago

Resolution: fixed
Status: newclosed

This test has been modified for Python 3 compatibility, and now it passes even when default encoding is utf-8. I think that having a default encoding different from 'ascii' or 'utf-8' is probably doomed to fail anyway in many other cases.

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