Skip to content

Commit

Permalink
add long str
Browse files Browse the repository at this point in the history
  • Loading branch information
Ирина Карачакова committed Apr 4, 2023
1 parent 36f84dc commit 7c226da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions vedro/plugins/director/rich/_rich_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def print_scope_key(self, key: str, *, indent: int = 0, line_break: bool = False
end = "\n" if line_break else ""
self._console.out(f"{prepend}{key}: ", end=end, style=Style(color="blue"))

def cut_str(string: str, length: int, separator: str = "...") -> str:
def cut_str(self, string: str, length: int, separator: str = "...") -> str:
assert length > len(separator)

if len(string) <= length:
Expand All @@ -168,13 +168,13 @@ def cut_str(string: str, length: int, separator: str = "...") -> str:
length -= len(separator)
return string[:length // 2] + separator + string[-length // 2:]

def fold_long_strings(self, input_str, long_str):
def fold_long_strings(self, input_str: str, length_long_str: int) -> str:
strs = input_str.split('\n')
output_list = [cut_str(item, length=long_str) for item in strs]
output_list = [self.cut_str(item, length=length_long_str) for item in strs]
return '\n'.join(output_list)

def print_scope_val(self, val: Any, long_str) -> None:
val_folded_str = self.fold_long_strings(val, long_str)
def print_scope_val(self, val: Any, length_long_str: int) -> None:
val_folded_str = self.fold_long_strings(val, length_long_str)
self._console.print(val_folded_str)

def print_interrupted(self, exc_info: ExcInfo, *, show_traceback: bool = False) -> None:
Expand Down
7 changes: 4 additions & 3 deletions vedro/plugins/director/rich/_rich_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, config: Type["RichReporter"], *,
self._tb_pretty = config.tb_pretty
self._tb_show_internal_calls = config.tb_show_internal_calls
self._tb_show_locals = config.tb_show_locals
self._tb_long_str = config.tb_long_str
self._tb_length_long_str = config.tb_length_long_str
self._tb_max_frames = config.tb_max_frames
self._show_skipped = config.show_skipped
self._show_timings = config.show_timings
Expand Down Expand Up @@ -182,7 +182,8 @@ def _print_scenario_failed(self, scenario_result: ScenarioResult, *, prefix: str

if self._verbosity > 2:
if scenario_result.scope:
self._printer.print_scope(scenario_result.scope, long_str=self._tb_long_str)
self._printer.print_scope(scenario_result.scope,
length_long_str=self._tb_length_long_str)

def _print_scenario_skipped(self, scenario_result: ScenarioResult, *,
prefix: str = "") -> None:
Expand Down Expand Up @@ -270,7 +271,7 @@ class RichReporter(PluginConfig):
tb_show_locals: bool = False

# Shortens long lines
tb_long_str: int = 1000
tb_length_long_str: int = 1000

# Max stack trace entries to show (min=4)
tb_max_frames: int = 8
Expand Down

0 comments on commit 7c226da

Please sign in to comment.