-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-126332: Add tests for _pyrepl.utils #129325
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
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
07715bf
Add tests for _pyrepr.utils
eendebakpt 3699678
📜🤖 Added by blurb_it.
blurb-it[bot] ab78d05
Merge branch 'main' into pyrepl_utils
eendebakpt 8596419
Merge branch 'main' into pyrepl_utils
eendebakpt 5ce442a
improve test
eendebakpt 7bd56b9
Merge branch 'main' into pyrepl_utils
eendebakpt 0782750
Merge branch 'main' into pyrepl_utils
vstinner b17710e
fix news entry name
eendebakpt deda6ad
Merge branch 'main' into pyrepl_utils
eendebakpt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from unittest import TestCase | ||
|
||
from _pyrepl.utils import str_width, wlen | ||
|
||
|
||
class TestUtils(TestCase): | ||
def test_str_width(self): | ||
characters = ['a', '1', '_', '!', '\x1a', '\u263A', '\uffb9'] | ||
for c in characters: | ||
self.assertEqual(str_width(c), 1) | ||
|
||
characters = [chr(99989), chr(99999)] | ||
for c in characters: | ||
self.assertEqual(str_width(c), 2) | ||
|
||
def test_wlen(self): | ||
for c in ['a', 'b', '1', '!', '_']: | ||
self.assertEqual(wlen(c), 1) | ||
self.assertEqual(wlen('\x1a'), 2) | ||
|
||
self.assertEqual(wlen('hello'), 5) | ||
self.assertEqual(wlen('hello'+'\x1a'), 7) | ||
self.assertEqual(wlen('hello'+'\0x1B'), 9) | ||
1 change: 1 addition & 0 deletions
1
Misc/NEWS.d/next/Library/2025-01-26-20-17-58.gh-issue-gh-126332.c0wUS-.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add unit tests for pyrepl. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is strange. Are you testing the nul byte and then the string
x1B
on purpose?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I tried to create a special unicode character to hit one of the paths in wlen, but think I made a typo. I removed this test and added two others.