8000 [mypyc] Add tests for chr(), ord(), encode() and decode() by 97littleleaf11 · Pull Request #10914 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

[mypyc] Add tests for chr(), ord(), encode() and decode() #10914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 5, 2021

Conversation

97littleleaf11
Copy link
Collaborator

Description

Add several run tests:

  • chr()
  • ord()
  • decode()
  • encode()

@97littleleaf11 97littleleaf11 marked this pull request as ready for review August 3, 2021 09:01
Copy link
Collaborator
@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some ideas about further things to test.

@97littleleaf11 97littleleaf11 requested a review from JukkaL August 3, 2021 17:30
Copy link
Collaborator
@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates! Left a few additional ideas.

assert "\U00000394" == '\u0394'
assert b'\x80abc'.decode("utf-8", "replace") == '\ufffdabc'
assert b'\x80abc'.decode("utf-8", "backslashreplace") == '\\x80abc'
assert b'\x80abc'.decode("utf-8", "ignore") == 'abc'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more ideas: Test decode exception, test latin1, test some different spellings (utf8, utf_8 and Utf-8 all seem to work).

assert u.encode('ascii', 'xmlcharrefreplace') == b'ꀀabcd޴'
assert u.encode('ascii', 'backslashreplace') == b'\\ua000abcd\\u07b4'
assert u.encode('ascii', 'namereplace') == b'\\N{YI SYLLABLE IT}abcd\\u07b4'
assert 'pythön!'.encode() == b'pyth\xc3\xb6n!'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test latin1, test some different spellings (as above).

@JukkaL
Copy link
Collaborator
JukkaL commented Aug 4, 2021

Also please update the name of the PR to mention chr and ord.

@97littleleaf11 97littleleaf11 changed the title [mypyc] Add tests for encode() and decode() [mypyc] Add tests for chr(), ord(), encode() and decode() Aug 4, 2021
@97littleleaf11 97littleleaf11 requested a review from JukkaL August 4, 2021 13:26
@JukkaL
Copy link
Collaborator
JukkaL commented Aug 5, 2021

Can you rebase? This should fix CI.

Copy link
Collaborator
@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now!

@JukkaL JukkaL merged commit 68a67ae into python:master Aug 5, 2021
@97littleleaf11 97littleleaf11 deleted the add-encode-decode-tests branch August 5, 2021 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0