Implement tests for singleton decorator#2107
Open
kivancbeser wants to merge 4 commits intoOpenMind:mainfrom
Open
Implement tests for singleton decorator#2107kivancbeser wants to merge 4 commits intoOpenMind:mainfrom
kivancbeser wants to merge 4 commits intoOpenMind:mainfrom
Conversation
Add tests for singleton decorator functionality including basic instance equality, reset behavior, and thread safety.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Collaborator
|
@kivancbeser |
Author
Fixed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add tests for singleton decorator functionality including basic instance equality, reset behavior, and thread safety.
Overview
This PR adds comprehensive unit tests for the singleton decorator located in src/providers/singleton.py. While the core logic was partially covered by indirect usage, these dedicated tests ensure that the singleton pattern remains robust as the project grows.
Type of change
Changes
Created tests/providers/test_singleton_provider.py.
Added test_singleton_basic_functionality to verify instance equality.
Added test_singleton_reset to verify the instance clearing mechanism.
Added test_singleton_thread_safety using the threading module to ensure the decorator is safe for concurrent access (race condition prevention).
Checklist
Impact
This change has no risk to the existing codebase as it only adds test files. It improves the reliability of the singleton utility, which is a foundational component used across various providers in OM1.
Additional Information
Local test results:
collected 3 items
tests/providers/test_singleton_provider.py ... [100%]
============================== 3 passed in 0.11s ==============================