Skip to content

Fix for nested Mocketizer's decorators - #327

Merged
mindflayer merged 8 commits into
mainfrom
fix-nested-decorators
Aug 26, 2026
Merged

Fix for nested Mocketizer's decorators#327
mindflayer merged 8 commits into
mainfrom
fix-nested-decorators

Conversation

@mindflayer

Copy link
Copy Markdown
Owner

Fix for #326

Copilot AI lite review requested due to automatic review settings August 26, 2026 05:50
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.85%. Comparing base (d1bd1d6) to head (60a36fc).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #327      +/-   ##
==========================================
+ Coverage   98.09%   98.85%   +0.76%     
==========================================
  Files          22       22              
  Lines        1207     1224      +17     
==========================================
+ Hits         1184     1210      +26     
+ Misses         23       14       -9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new regression test performs an unguarded real HTTP request (likely flaky/offline-dependent) and should be consistent with existing SKIP_TRUE_HTTP-guarded true-HTTP tests.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes a regression where nested Mocketizer/@mocketize activations could fail to restore the original socket patches and/or STRICT mode, causing STRICT mode to leak into subsequent tests (Issue #326).

Changes:

  • Add nested enable/disable depth tracking in mocket.inject to avoid overwriting original patch-restore values during re-entrant activation.
  • Make Mocketizer restore MocketMode.STRICT / STRICT_ALLOWED on exit even when teardown/disable raises.
  • Add regression tests for STRICT mode and patch restoration; bump pre-commit hook revisions.
File summaries
File Description
tests/test_mode.py Adds a regression test ensuring STRICT mode from an inner @mocketize does not leak beyond an outer context.
tests/test_mocket.py Adds a regression test for nested Mocketizer ensuring socket patches and STRICT mode are restored.
mocket/inject.py Introduces _enable_depth to make patching/restoring re-entrant-safe for nested activations.
mocket/decorators/mocketizer.py Stores/restores prior STRICT mode settings on exit (with finally for robustness).
.pre-commit-config.yaml Updates ruff and rstcheck hook versions.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread mocket/inject.py Outdated
Comment thread tests/test_mocket.py Outdated
mindflayer and others added 2 commits August 26, 2026 07:58
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI and others added 2 commits August 26, 2026 06:00
Co-authored-by: mindflayer <527325+mindflayer@users.noreply.github.com>
Co-authored-by: mindflayer <527325+mindflayer@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

@mindflayer
mindflayer merged commit 3419f1c into main Aug 26, 2026
12 checks passed
@mindflayer
mindflayer deleted the fix-nested-decorators branch August 26, 2026 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants