Skip to content

Commit

Permalink
Update reset_tests.py
Browse files Browse the repository at this point in the history
Minor code and documentation fixes in reset_tests.py
  • Loading branch information
rahul4732saini committed Jul 30, 2024
1 parent 4965880 commit 0fac144
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/reset_tests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"""
Reset Tests Module
------------------
This module provides utilities to reset the test directories by regenerating them
based on the file and directory listings stored in the `test_directory.hdf` file.
This module provides utility functions to reset the test directories
by regenerating them based on the file and directory listings stored
in the `test_directory.hdf` file.
"""

import shutil
Expand All @@ -11,18 +13,18 @@
import pandas as pd

FILE_DIR_TEST_DIRECTORY = Path(__file__).parent / "test_directory" / "file_dir"
FILE_DIR_TEST_DIRECTORY_LISTINGS = Path(__file__).parent / "test_directory.hdf"
FILE_DIR_TEST_DIRECTORY_LISTINGS_FILE = Path(__file__).parent / "test_directory.hdf"


def reset_file_dir_test_directory(
directory: Path = FILE_DIR_TEST_DIRECTORY,
listings: Path = FILE_DIR_TEST_DIRECTORY_LISTINGS,
listings: Path = FILE_DIR_TEST_DIRECTORY_LISTINGS_FILE,
):
"""
Resets the `file_dir` test directory.
Deletes the existing `file_dir` test directory and recreates it based
on the directory and file listings stored in the specified HDF5 file.
on the file and directory listings stored in the specified HDF5 file.
"""

if directory.exists():
Expand All @@ -34,10 +36,10 @@ def reset_file_dir_test_directory(
dir_listings: pd.Series[str] = store["/file_dir/dirs"]

for direc in dir_listings:
directory.joinpath(direc).mkdir()
(directory / direc).mkdir()

for file in file_listings:
directory.joinpath(file).touch()
(directory / file).mkdir()


if __name__ == "__main__":
Expand Down

0 comments on commit 0fac144

Please sign in to comment.