CleanCut / green

Green is a clean, colorful, fast python test runner.
MIT License
791 stars 75 forks source link

Error messages on Windows breaks on Unicode #119

Closed MinchinWeb closed 8 years ago

MinchinWeb commented 8 years ago

Windows has various issues around Unicode. The particular issue I'm running into with green is a test will fail due to a unicode issue (often the program under test will attempt to print something unicode to CMD), but when green tries to print the resulting error message, it breaks as the error message contains the unicode character in question. Thus, I only learn of the first test that failed, and not why any of the tests after that failed.

Would it be possible to run the error messages through something like Unidecode, at least on Windows, before dumping it to CMD?

CleanCut commented 8 years ago

Fine with me. Did you want to submit a pull request? If not, it would be helpful if you could send me one of the crash cases. On Fri, Apr 8, 2016 at 10:21 PM MinchinWeb notifications@github.com wrote:

Windows has various issues around Unicode. The particular issue I'm running into with green is a test will fail due to a unicode issue (often the program under test will attempt to print something unicode to CMD), but when green tries to print the resulting error message, it breaks as the error message contains the unicode character in question. Thus, I only learn of the first test that failed, and not why any of the tests after that failed.

Would it be possible to run the error messages through something like Unidecode https://pypi.python.org/pypi/Unidecode, at least on Windows, before dumping it to CMD?

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/CleanCut/green/issues/119

MinchinWeb commented 8 years ago

Ok, I think I put together working code. I'm not sure how to add a test though... Here's what I'm using as a manual testcase on my end:

import unittest

class UnicodeTest(unittest.TestCase):
    def test1(self):
        print('\u03BB')  # lambda
        self.assertTrue(True)

    def test2(self):
        self.assertTrue(False)

And the output (with green working):

image

Suggestions?