Skip to content

ci,docs: Add Pyright checks to tests, add contributing docs #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 26, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
docs: Updated docs and added col width test
  • Loading branch information
DenverCoder1 committed Jun 26, 2022
commit 30be1b1c6dcb36aa1cc241f2bcce7586d7d36533
2 changes: 1 addition & 1 deletion table2ascii/table_to_ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def table2ascii(
footer (:class:`Optional[List[Any]]`): List of column values in the table's footer row
first_col_heading (:class:`bool`): Whether to add a header column separator after the first column
last_col_heading (:class:`bool`): Whether to add a header column separator before the last column
column_widths (:class:`List[int]`): List of widths in characters for each column (defaults to auto-sizing)
column_widths (:class:`Optional[List[int]]`): List of widths in characters for each column (``None`` for auto-sizing)
alignments (:class:`List[Alignment]`): List of alignments (ex. `[Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT]`)
style (:class:`TableStyle`): Table style to use for styling (preset styles can be imported)

Expand Down
22 changes: 22 additions & 0 deletions tests/test_column_widths.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@ def test_column_widths():
assert text == expected


def test_column_widths_none():
text = t2a(
header=["#", "G", "H", "R", "S"],
body=[["1", "30", "40", "35", "30"], ["2", "30", "40", "35", "30"]],
footer=["TOTL", "130", "140", "135", "130"],
first_col_heading=True,
last_col_heading=True,
column_widths=None,
)
expected = (
"╔══════╦═════════════════╦═════╗\n"
"║ # ║ G H R ║ S ║\n"
"╟──────╫─────────────────╫─────╢\n"
"║ 1 ║ 30 40 35 ║ 30 ║\n"
"║ 2 ║ 30 40 35 ║ 30 ║\n"
"╟──────╫─────────────────╫─────╢\n"
"║ TOTL ║ 130 140 135 ║ 130 ║\n"
"╚══════╩═════════════════╩═════╝"
)
assert text == expected


def test_wrong_number_column_widths():
with pytest.raises(ValueError):
t2a(
Expand Down