This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [2.7] unittest: Unicode support in TestCase.skip
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: Nathan Buckner, ezio.melotti, michael.foord, rbcollins, serhiy.storchaka, vstinner
Priority: normal Keywords:

Created on 2017-08-24 20:37 by Nathan Buckner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue.txt Nathan Buckner, 2017-08-24 20:37
Messages (3)
msg300802 - (view) Author: Nathan Buckner (Nathan Buckner) Date: 2017-08-24 20:37
Unicode support for TestCase.skip is broken because the caught SkipTest exception is passed through a str call.
except SkipTest as e:
    self._addSkip(result, str(e))
Could be fixed with by changing to unicode(e)
msg305232 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-30 15:44
> Could be fixed with by changing to unicode(e)

Replacing str(e) with unicode(e) can introduce Unicode errors regressions. I'm not confident in doing such change late in the old 2.7 branch.

I suggest you to only use native strings (byte strings, "str" type) in Python 2, and slowly upgrade your application to Python 3.

I propose to close this issue as WONT FIX.
msg305234 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-30 15:55
I concur with Victor. Unlikely this affects many people since skipping messages usually are ASCII strings.

As a workaround you can implement your own skip() method that encodes unicode to 8-bit string.

    def skip(self, reason):
        if isinstance(reason, unicode):
            reason = unicode.encode(reason, 'utf-8')
        TestCase.skip(self, reason)
History
Date User Action Args
2022-04-11 14:58:51adminsetgithub: 75456
2017-10-30 15:55:20serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg305234

resolution: wont fix
stage: needs patch -> resolved
2017-10-30 15:44:10vstinnersetmessages: + msg305232
title: Unicode support in TestCase.skip -> [2.7] unittest: Unicode support in TestCase.skip
2017-10-29 02:35:15berker.peksagsetnosy: + rbcollins, michael.foord

type: crash -> behavior
components: + Library (Lib), - Tests, Unicode
stage: needs patch
2017-08-24 20:37:13Nathan Bucknercreate