Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Strange output with non-ascii string

See original GitHub issue

Platform: Windows 10 64bit Python: 3.7 Shell: Powershell 6.1.1

Test code:
from unittest import TestCase

class OutputTests(TestCase):
    def test_success(self):
        self.assertEqual("lang: 日本語", "lang: 日本語")

    def test_fail(self):
        self.assertEqual("lang: 日本語", "lang: English")

Output by Green:

test_green OutputTests F test_fail . test_success

Failure in test_green.OutputTests.test_fail // Traceback here AssertionError: 'lang: Ri Ben Yu ’ != ‘lang: English’ - lang: Ri Ben Yu + lang: English

Ran 2 tests in 0.740s

FAILED (failures=1, passes=1)

Output by builtin unittest:


====================================================================== FAIL: test_fail (test_green.OutputTests) ---------------------------------------------------------------------- //Traceback here AssertionError: ‘lang: 日本語’ != ‘lang: English’ - lang: 日本語 + lang: English

---------------------------------------------------------------------- Ran 2 tests in 0.002s

FAILED (failures=1)

Test finished as expected, but that is wrong output(日本語->Ri Ben Yu ).

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

CleanCutcommented, Mar 16, 2019

Fix is in 2.14.0, just released.

tkamenokocommented, Feb 16, 2019

Yes, I think so. Current behavior is not documented and may lead to confusion. The same output as builtin unittest is required.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Strange literal when using non-ascii characters in string
1 Answer 1 · It's a UTF-8-encoded string. The fact that it's printing correctly shows that your terminal happens to be using UTF-8,...
Read more >
Non-ascii characters in files · Issue #81 · lbl-srg/BuildingsPy
It's hard to reproduce since I have no idea how these weird characters get into the file. When I come across another one...
Read more >
Code Inspection: Non-ASCII characters | PhpStorm ... - JetBrains
Reports code elements that use non-ASCII symbols in an unusual context. ... Non-ASCII characters used in identifiers, strings, or comments.
Read more >
Remove non-ASCII characters from a string in Python
To remove the non-ASCII characters from a string, check if each character in the string has a unicode code point less than 128....
Read more >
Character Numbers' Weird Behavior in TeX for Non-ASCII ...
Just tested the same thing with XeTeX, totally different numbers where outputted, each number different and unique. Can someone please explain ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found