Code

Opened 2 years ago

Closed 20 months 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 claudep 2 years ago.
Skip if default encoding is not ascii

Download all attachments as: .zip

Change History (3)

Changed 2 years ago by claudep

Skip if default encoding is not ascii

comment:1 Changed 2 years ago by claudep

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 20 months ago by claudep

  • Resolution set to fixed
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.