Skip to content

feat: added Client.test_mode() to prevent subprocess locking#52

Merged
petruki merged 1 commit intomasterfrom
staging
Apr 28, 2026
Merged

feat: added Client.test_mode() to prevent subprocess locking#52
petruki merged 1 commit intomasterfrom
staging

Conversation

@petruki
Copy link
Copy Markdown
Member

@petruki petruki commented Apr 28, 2026

This pull request introduces a new "test mode" to the Client class, designed to prevent subprocesses like the snapshot watcher from running during tests. This makes it easier to avoid file locking issues in test environments. The implementation adds a new error type, updates documentation, and includes a test to verify the new behavior.

Key changes:

Test Mode Feature Implementation

  • Added a _test_mode flag to the Client class, initialized with DEFAULT_TEST_MODE, and a static test_mode() method to enable test mode and prevent subprocesses during tests (switcher_client/client.py). [1] [2] [3]
  • Updated the watch_snapshot method to reject snapshot watching in test mode, raising a new TestModeError (switcher_client/client.py).

Error Handling

  • Introduced a new TestModeError exception to signal operations that are not allowed in test mode, and exported it in the module's __all__ list (switcher_client/errors/__init__.py).
  • Updated imports to include TestModeError where needed (switcher_client/client.py).

Documentation

  • Updated the README to document the new test mode functionality and its usage (README.md).

Testing

  • Added a unit test to verify that the snapshot watcher is blocked when test mode is enabled (tests/test_client_watch_snapshot.py).

@petruki petruki added this to the v1.0.0 milestone Apr 28, 2026
@petruki petruki self-assigned this Apr 28, 2026
@petruki petruki added the enhancement New feature or request label Apr 28, 2026
@sonarqubecloud
Copy link
Copy Markdown

@petruki petruki merged commit 3abae08 into master Apr 28, 2026
15 checks passed
@petruki petruki deleted the staging branch April 28, 2026 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant