Skip to content

Commit

Permalink
fix tests for windows (#318)
Browse files Browse the repository at this point in the history
* fix tests for windows

* flush buffer in tests
  • Loading branch information
dllliu authored Sep 12, 2024
1 parent 43e5b3e commit 06d969e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tests/unit/dataclasses/test_template_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ def test_template_generation_inmemory(
template = template.inline_dependencies()
bindings, filled = template.fill(BLDG, include_optional=include_optional)

with NamedTemporaryFile(suffix=".xlsx") as dest:
with NamedTemporaryFile(suffix=".xlsx", delete=False) as dest:
output = template.generate_spreadsheet()
assert output is not None
dest.write(output.getbuffer())

dest.flush()
w = openpyxl.load_workbook(dest.name)
_add_spreadsheet_row(w.active, bindings)
w.save(Path(dest.name))
Expand All @@ -92,10 +92,10 @@ def test_template_generation_file(
template = template.inline_dependencies()
bindings, filled = template.fill(BLDG, include_optional=include_optional)

with NamedTemporaryFile(suffix=".xlsx") as dest:
with NamedTemporaryFile(suffix=".xlsx", delete=False) as dest:
output = template.generate_spreadsheet(Path(dest.name))
assert output is None

dest.flush()
w = openpyxl.load_workbook(dest.name)
_add_spreadsheet_row(w.active, bindings)
w.save(Path(dest.name))
Expand All @@ -118,7 +118,7 @@ def test_csv_generation_inmemory(
template = template.inline_dependencies()
bindings, filled = template.fill(BLDG, include_optional=include_optional)

with NamedTemporaryFile(mode="w", suffix=".csv") as dest:
with NamedTemporaryFile(mode="w", suffix=".csv", delete=False) as dest:
output = template.generate_csv()
assert output is not None
dest.writelines([output.getvalue()])
Expand All @@ -145,9 +145,10 @@ def test_csv_generation_file(
template = template.inline_dependencies()
bindings, filled = template.fill(BLDG, include_optional=include_optional)

with NamedTemporaryFile(mode="w", suffix=".csv") as dest:
with NamedTemporaryFile(mode="w", suffix=".csv", delete=False) as dest:
output = template.generate_csv(Path(dest.name))
assert output is None
dest.flush()

with open(Path(dest.name)) as f:
params = f.read().strip().split(",")
Expand Down

0 comments on commit 06d969e

Please sign in to comment.