diff options
author | Ran Benita <ran@unusedvar.com> | 2020-04-29 17:38:16 +0300 |
---|---|---|
committer | Ran Benita <ran@unusedvar.com> | 2020-04-30 16:44:03 +0300 |
commit | d9b43647b792ed71d92946edee17ded5d86eb6dc (patch) | |
tree | f58d1c7fb387bbb145053ddedaad38d65ad18dcb /src/_pytest/_io | |
parent | 8e04d35a3347a5e5b1152047d52e10032cfb509f (diff) | |
download | pytest-d9b43647b792ed71d92946edee17ded5d86eb6dc.tar.gz |
terminalwriter: inline function _update_chars_on_current_line
Diffstat (limited to 'src/_pytest/_io')
-rw-r--r-- | src/_pytest/_io/terminalwriter.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/_pytest/_io/terminalwriter.py b/src/_pytest/_io/terminalwriter.py index a4989a7f0..5db4dc8b6 100644 --- a/src/_pytest/_io/terminalwriter.py +++ b/src/_pytest/_io/terminalwriter.py @@ -157,7 +157,13 @@ class TerminalWriter: def write(self, msg: str, **kw: bool) -> None: if msg: - self._update_chars_on_current_line(msg) + current_line = msg.rsplit("\n", 1)[-1] + if "\n" in msg: + self._chars_on_current_line = len(current_line) + self._width_of_current_line = get_line_width(current_line) + else: + self._chars_on_current_line += len(current_line) + self._width_of_current_line += get_line_width(current_line) if self.hasmarkup and kw: markupmsg = self.markup(msg, **kw) @@ -166,15 +172,6 @@ class TerminalWriter: self._file.write(markupmsg) self._file.flush() - def _update_chars_on_current_line(self, text: str) -> None: - current_line = text.rsplit("\n", 1)[-1] - if "\n" in text: - self._chars_on_current_line = len(current_line) - self._width_of_current_line = get_line_width(current_line) - else: - self._chars_on_current_line += len(current_line) - self._width_of_current_line += get_line_width(current_line) - def line(self, s: str = "", **kw: bool) -> None: self.write(s, **kw) self.write("\n") |