follow-up: Improve test isolation by resetting shared context variables between tests for test_gitlab_workflow.py
Problem
Reference comment - !3372 (comment 2784735948)
Currently, tests use shared context variables (like current_user) that can leak state between test runs, potentially causing flaky test behavior in CI
pipelines.
Example from tests/duo_workflow_service/checkpointer/test_gitlab_workflow.py:
current_user.set(mock_user)
Impact
- Risk of flaky test assertions due to state leakage
- Tests may pass/fail inconsistently depending on execution order
- Reduced reliability of CI pipeline
Proposed Solution
Ensure all shared context variables are properly reset after each test. This could involve:
- Teardown methods: Add cleanup in test teardown to reset context variables
- Test fixtures: Create fixtures that automatically clean up context after each test
- Explicit mocking: Use more isolated mocking strategies per test
Scope
This affects multiple test files across the codebase where shared context variables are used. A codebase-wide audit should identify all instances of this pattern.