-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
good first issueeasy issue that is friendly to new contributoreasy issue that is friendly to new contributortopic: reportingrelated to terminal output and user-facing messages and errorsrelated to terminal output and user-facing messages and errorstopic: rewriterelated to the assertion rewrite mechanismrelated to the assertion rewrite mechanism
Description
If I compare same string in different Unicode normal forms the error message doesn't show any differences between them when using Python 3. For example, if I have a test like
def test_nfc_nfd():
nfc = 'hyv\xe4'
nfd = 'hyva\u0308'
assert nfc == nfd
the result I got is
> assert nfc == nfd
E AssertionError: assert 'hyvä' == 'hyvä'
E - hyvä
E + hyvä
which isn't very informative.
The problem is caused by repr('hyva\u0308')
being 'hyva\u0308'
which is rendered as 'hyvä'
. I submitted an issue about repr()
escaping combining characters (i.e. turning the result to 'hyva\\u0308'
) but it was closed as invalid.
In PyTest it would be possible to use ascii()
instead of repr()
, but that would make all non-ASCII strings unreadable and that would be worse. I guess the best solution would be using ascii()
if strings look the same, but I have no idea how to detect that.
Metadata
Metadata
Assignees
Labels
good first issueeasy issue that is friendly to new contributoreasy issue that is friendly to new contributortopic: reportingrelated to terminal output and user-facing messages and errorsrelated to terminal output and user-facing messages and errorstopic: rewriterelated to the assertion rewrite mechanismrelated to the assertion rewrite mechanism