Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
31 changes: 21 additions & 10 deletions gptables/test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def generate_gpworkbook(output_path):
)

gpt.write_workbook( # Use defaults for theme and autowidth
filename=output_path / "actual_workbook.xlsx",
filename=output_path / "test_end_to_end.obtained.xlsx",
sheets={"Label": gptable},
cover=cover,
contentsheet_label="Table of contents",
Expand All @@ -68,21 +68,32 @@ def generate_gpworkbook(output_path):
return generate_gpworkbook


def test_end_to_end(create_gpworkbook):
def test_end_to_end(create_gpworkbook, file_regression):
"""
Test that runs the API functions with example input to check for errors and
expected output.
Test that runs the API functions with example input and checks the generated Excel
file using a manually managed expected_workbook.xlsx and ExcelComparisonTest.
"""
output_path = Path(__file__).parent

output_path = Path(__file__).parent / "test_api"
output_path.mkdir(parents=True, exist_ok=True)
create_gpworkbook(output_path)
actual_file = output_path / "test_end_to_end.obtained.xlsx"

# Use file_regression to manage the regression file, but ignore its assertion
try:
file_regression.check(actual_file.read_bytes(), extension=".xlsx", binary=True)
except AssertionError:
pass

regression_file = output_path / "test_end_to_end.xlsx"
if not regression_file.exists():
raise FileNotFoundError(
f"Could not find regression file for comparison: {regression_file}"
)

ect = ExcelComparisonTest()

ect.exp_filename = output_path / "expected_workbook.xlsx"
ect.got_filename = output_path / "actual_workbook.xlsx"
ect.got_filename = str(actual_file)
ect.exp_filename = str(regression_file)
ect.ignore_files = []
ect.ignore_elements = {}

ect.assertExcelEqual()
ect.tearDown()
Binary file not shown.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ dev = [
"pytest>=8.4.2",
"pytest-cov",
"pre-commit",
"importlib_resources"
"importlib_resources",
"pytest-regressions"
]

[version]
Expand Down