Skip to content
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

Close regression data files #2843

Merged
merged 5 commits into from
Oct 21, 2024
Merged
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
12 changes: 9 additions & 3 deletions tardis/tests/fixtures/regression_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, request) -> None:
"--generate-reference"
)
self.fname = f"{self.fname_prefix}.UNKNOWN_FORMAT"
self.hdf_store_object = None

@property
def module_name(self):
Expand Down Expand Up @@ -161,9 +162,14 @@ def sync_hdf_store(self, tardis_module, update_fname=True):
f"Skipping test to generate regression data: {self.fpath}"
)
else:
return pd.HDFStore(self.fpath, mode="r")

# since each test function has its own regression data instance
# each test function will only have one HDFStore object
self.hdf_store_object = pd.HDFStore(self.fpath, mode="r")
return self.hdf_store_object
atharva-2001 marked this conversation as resolved.
Show resolved Hide resolved

@pytest.fixture(scope="function")
def regression_data(request):
return RegressionData(request)
regression_data_instance = RegressionData(request)
yield regression_data_instance
if regression_data_instance.hdf_store_object:
regression_data_instance.hdf_store_object.close()
Loading