-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #196 from wimglenn/better_line_width_estimate
i18n: more accurate line width estimate...possible?
- Loading branch information
Showing
4 changed files
with
102 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -22,3 +22,4 @@ Jan Balster | |
Grig Gheorghiu | ||
Bob Ippolito | ||
Christian Tismer | ||
Wim Glenn |
This file contains 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
This file contains 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
This file contains 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,56 @@ | ||
# coding: utf-8 | ||
from __future__ import unicode_literals | ||
|
||
from py._io.terminalwriter import TerminalWriter | ||
|
||
|
||
def test_terminal_writer_line_width_init(): | ||
tw = TerminalWriter() | ||
assert tw.chars_on_current_line == 0 | ||
assert tw.width_of_current_line == 0 | ||
|
||
|
||
def test_terminal_writer_line_width_update(): | ||
tw = TerminalWriter() | ||
tw.write('hello world') | ||
assert tw.chars_on_current_line == 11 | ||
assert tw.width_of_current_line == 11 | ||
|
||
|
||
def test_terminal_writer_line_width_update_with_newline(): | ||
tw = TerminalWriter() | ||
tw.write('hello\nworld') | ||
assert tw.chars_on_current_line == 5 | ||
assert tw.width_of_current_line == 5 | ||
|
||
|
||
def test_terminal_writer_line_width_update_with_wide_text(): | ||
tw = TerminalWriter() | ||
tw.write('乇乂ㄒ尺卂 ㄒ卄丨匚匚') | ||
assert tw.chars_on_current_line == 11 | ||
assert tw.width_of_current_line == 21 # 5*2 + 1 + 5*2 | ||
|
||
|
||
def test_terminal_writer_line_width_update_with_wide_bytes(): | ||
tw = TerminalWriter() | ||
tw.write('乇乂ㄒ尺卂 ㄒ卄丨匚匚'.encode('utf-8')) | ||
assert tw.chars_on_current_line == 11 | ||
assert tw.width_of_current_line == 21 | ||
|
||
|
||
def test_terminal_writer_line_width_composed(): | ||
tw = TerminalWriter() | ||
text = 'café food' | ||
assert len(text) == 9 | ||
tw.write(text) | ||
assert tw.chars_on_current_line == 9 | ||
assert tw.width_of_current_line == 9 | ||
|
||
|
||
def test_terminal_writer_line_width_combining(): | ||
tw = TerminalWriter() | ||
text = 'café food' | ||
assert len(text) == 10 | ||
tw.write(text) | ||
assert tw.chars_on_current_line == 10 | ||
assert tw.width_of_current_line == 9 |