Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 8, 2022
1 parent 3646520 commit bd7183d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/prettytable/prettytable.py
Original file line number Diff line number Diff line change
Expand Up @@ -1585,11 +1585,11 @@ def _compute_widths(self, rows, options):
min_width = max(title_width, min_table_width)
table_width = self._compute_table_width(options)
if table_width < min_width:
# To make enough space for the title, all columns have to
# grow enough that their combined widths (and the borders
# To make enough space for the title, all columns have to
# grow enough that their combined widths (and the borders
# between them) are equal to the length of the title.
border_char_count = 3 * (len(widths) - 1)
scale = 1.0 * (len(options['title']) - border_char_count) / sum(widths)
border_char_count = 3 * (len(widths) - 1)
scale = 1.0 * (len(options["title"]) - border_char_count) / sum(widths)
widths = [int(math.ceil(w * scale)) for w in widths]
self._widths = widths

Expand Down
8 changes: 5 additions & 3 deletions tests/test_prettytable.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,10 +555,12 @@ def test_all_lengths_equal_with_title(self, city_data_prettytable: PrettyTable):
city_data_prettytable.title = "My table"
self._test_all_length_equal(city_data_prettytable)

def test_all_lengths_equal_with_long_title(self, city_data_prettytable: PrettyTable):
def test_all_lengths_equal_with_long_title(
self, city_data_prettytable: PrettyTable
):
"""All lines in a table should be of the same length, even with a long title."""
city_data_prettytable.title = "My table (75 characters wide) " + "="*45
self._test_all_length_equal(city_data_prettytable)
city_data_prettytable.title = "My table (75 characters wide) " + "=" * 45
self._test_all_length_equal(city_data_prettytable)

def test_no_blank_lines_without_border(self, city_data_prettytable: PrettyTable):
"""No table should ever have blank lines in it."""
Expand Down

0 comments on commit bd7183d

Please sign in to comment.