Conversation
|
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.



This pull request introduces a new decorator-based testing API for feature flag mocking in the Switcher Client SDK for Python, along with updates to documentation and comprehensive tests. The main goal is to simplify and improve the safety of mocking feature flags in test scenarios, making it easier to isolate and clean up mocks automatically after each test, including support for both synchronous and asynchronous test functions.
Key changes:
Decorator-Based Test Mocking API:
switcher_client/testing.pymodule with theassume_testbuilder andswitcher_testdecorator, enabling test-scoped, fluent, and safe mocking of feature flags with automatic cleanup, even on errors or in async tests. This ensures mocks do not leak between tests and supports advanced mocking rules and metadata.assume_testandswitcher_testfrom the SDK’s main module (switcher_client/__init__.py) for easy import by users. [1] [2]Documentation Updates:
README.mdto describe the new decorator-based mocking approach, including usage examples, behavior, and limitations, and clarified the mocking feature description. [1] [2] [3] [4]Testing and Validation:
tests/test_switcher_stub_decorator.pywith comprehensive unit tests covering all aspects of the new decorator API, including error handling, cleanup, support for metadata, multiple mocks, context isolation, and async test support.Minor Improvements:
LoadSnapshotOptionsto be imported from the main SDK entrypoint.These changes collectively make feature flag mocking for testing more robust, convenient, and less error-prone for SDK users.