def test_consider_left_fraction( considerations: List[int], expect: Optional[int], ) -> None: layout = Layout() for consideration in considerations: layout.consider_left_fraction(consideration) assert layout.left_fraction_length == expect
def calculate_layout(self, style: Style) -> Layout: """ Calculates a layout to align all rows. """ layout = Layout() for row in self.rows: name_len = row.render_name(color=False, suffix=style.name_suffix)[1] layout.consider_name(name_len) if style.show_fraction: left_len = row.render_left_fraction(color=False)[1] layout.consider_left_fraction(left_len) right_len = row.render_right_fraction(color=False)[1] layout.consider_right_fraction(right_len) if style.show_percent: pc_len = row.render_percent(color=False, prefix=style.percent_prefix)[1] layout.consider_percent(pc_len) return layout