Skip to content

fix(test): Prevent creation of test_data directory during unit tests#41

Merged
keli-wen merged 2 commits into
masterfrom
fix_unittest_create_folder
Jul 27, 2025
Merged

fix(test): Prevent creation of test_data directory during unit tests#41
keli-wen merged 2 commits into
masterfrom
fix_unittest_create_folder

Conversation

@keli-wen

Copy link
Copy Markdown
Contributor

Description

This PR addresses an issue #39 where running unit tests would create an unexpected test_data directory. This side effect, caused by automatic directory creation in the global Setting model, has been removed to ensure a cleaner developer experience and prevent unintended file system modifications.

Key Changes

  • Removed Global Paths: The data_dir and temp_dir fields, along with their validating directory-creation logic, have been removed from the main Setting model in quantmind/config/settings.py.
  • Delegated Storage Config: Responsibility for storage paths is now fully delegated to the storage component (e.g., LocalStorageConfig), which manages its own directory structure.
  • Updated Tests: Unit tests in tests/config/test_settings.py have been updated to remove checks for the global paths and now perform their own cleanup of storage-related artifacts, ensuring tests are self-contained.
  • Updated Examples: All example configurations and scripts have been updated to reflect the new, cleaner structure.

Implementation Notes

The field_validator that created directories upon Setting initialization was the source of the unwanted side effects. By removing it and the associated fields, the Setting class becomes a pure data container, and components like LocalStorage properly encapsulate their own resource management. This enhances modularity and predictability.

Checklist

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [$CATEGORY] (such as [Docs], [Fix], [Feature], [Refactor])
  • Related issue is referred in this PR
  • The markdown and latex are rendered correctly.
  • The code in PR is well-documented.
  • The PR is complete and small, read the Google eng practice (CL equals to PR) to understand more about small PR.

@keli-wen keli-wen requested review from a team and wanghaoxue0 July 26, 2025 09:08
@keli-wen keli-wen self-assigned this Jul 26, 2025
@keli-wen keli-wen added the bug Something isn't working label Jul 26, 2025
@keli-wen keli-wen requested a review from pkudba July 26, 2025 11:18
Comment thread examples/config/default_config.yaml Outdated
@keli-wen keli-wen requested a review from WinstonLiyt July 27, 2025 05:56
@keli-wen keli-wen merged commit 409b54f into master Jul 27, 2025
1 check passed
@keli-wen keli-wen deleted the fix_unittest_create_folder branch July 27, 2025 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants