Skip to content

Commit

Permalink
apply reformat, added change log
Browse files Browse the repository at this point in the history
  • Loading branch information
noman404 committed Jan 29, 2025
1 parent 7db7a26 commit 2d52c5a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -795,3 +795,8 @@
fixed:
- Bug in parametric reforms.
date: 2025-01-28 07:08:07
- bump: patch
changes:
fixed:
- Fix file writing on windows.
date: 2025-01-30 02:31:17
2 changes: 1 addition & 1 deletion policyengine_core/tools/win_file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, logical_name: str):
def write(self, content: bytes):
with self.lock:
with tempfile.NamedTemporaryFile(
mode="wb", dir=self.base_dir, delete=False
mode="wb", dir=self.base_dir, delete=False
) as temp_file:
temp_file.write(content)
temp_file.flush()
Expand Down
10 changes: 7 additions & 3 deletions tests/core/data/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import threading
from policyengine_core.tools.win_file_manager import WindowsAtomicFileManager


def test_dataset_class():
from policyengine_core.data.dataset import Dataset
from policyengine_core.periods import period
Expand Down Expand Up @@ -62,7 +63,8 @@ def test_atomic_write_windows():
threads = []
for i in range(5):
thread = threading.Thread(
target=file_task, args=(managers[i], contents_list[i], check_results[i])
target=file_task,
args=(managers[i], contents_list[i], check_results[i]),
)
threads.append(thread)
thread.start()
Expand All @@ -72,12 +74,14 @@ def test_atomic_write_windows():

for i, results in enumerate(check_results):
for expected, actual in results:
assert expected == actual, f"Mismatch in file {i}: expected {expected}, got {actual}"
assert (
expected == actual
), f"Mismatch in file {i}: expected {expected}, got {actual}"


def file_task(manager, contents, check_results):
for content in contents:
manager.write(content)
actual_content = manager.read().decode()
expected_content = content.decode()
check_results.append((expected_content, actual_content))
check_results.append((expected_content, actual_content))

0 comments on commit 2d52c5a

Please sign in to comment.