Skip to content

Commit

Permalink
Add a test case where the number of rows exceeds the limit of 10
Browse files Browse the repository at this point in the history
Signed-off-by: Baden Ashford <[email protected]>
  • Loading branch information
kykyi committed Jan 25, 2024
1 parent 1ffbeca commit 1bb9b0c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pandera/backends/pandas/error_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,18 @@ def dataframe_to_tabular_formatted_string(
# Bottom border and additional rows message if applicable
if len(dataframe) > limit:
formatted_string += (
"│ " + " ┆ ".join(["…" for _ in column_widths.values()]) + " │\n"
"│"
+ "│".join(
[" " + "…" * (width) + " " for width in column_widths.values()]
)
+ "│\n"
)
formatted_string += (
"└"
+ "┴".join(["─" * (width + 2) for width in column_widths.values()])
+ "┘\n"
)
formatted_string += f"And {len(dataframe) - limit} others"
formatted_string += f"And {len(dataframe) - limit} more rows\n"
else:
formatted_string += (
"└"
Expand Down
29 changes: 29 additions & 0 deletions tests/core/test_error_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,35 @@ def _mock_custom_wide_check(df):
│ None │ Wide Schema │ _mock_custom_wide_ch │ False │ DataFrameSchema │ 0 │
│ │ │ eck │ │ │ │
└───────┴─────────────┴──────────────────────┴──────────────┴─────────────────┴──────────────┘
""",
),
(
DataFrameSchema(
{"count": Column(int, checks=[Check.greater_than(1)])}
),
pd.DataFrame(
{
"count": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
}
),
"""
Schema Nameless Schema: A total of 16 schema errors were found.
┌───────┬────────┬─────────────────┬──────────────┬────────────────┬──────────────┐
│ index ┆ column ┆ check ┆ failure_case ┆ schema_context ┆ check_number │
╞═══════╪════════╪═════════════════╪══════════════╪════════════════╪══════════════╡
│ 0 │ count │ greater_than(1) │ 0 │ Column │ 0 │
│ 1 │ count │ greater_than(1) │ 0 │ Column │ 0 │
│ 2 │ count │ greater_than(1) │ 0 │ Column │ 0 │
│ 3 │ count │ greater_than(1) │ 0 │ Column │ 0 │
│ 4 │ count │ greater_than(1) │ 0 │ Column │ 0 │
│ 5 │ count │ greater_than(1) │ 0 │ Column │ 0 │
│ 6 │ count │ greater_than(1) │ 0 │ Column │ 0 │
│ 7 │ count │ greater_than(1) │ 0 │ Column │ 0 │
│ 8 │ count │ greater_than(1) │ 0 │ Column │ 0 │
│ 9 │ count │ greater_than(1) │ 0 │ Column │ 0 │
│ …………… │ ……………… │ ……………………………………… │ ……………………………… │ …………………………………… │ ……………………………… │
└───────┴────────┴─────────────────┴──────────────┴────────────────┴──────────────┘
And 6 more rows
""",
),
],
Expand Down

0 comments on commit 1bb9b0c

Please sign in to comment.