Skip to content

fix(tests): Stop applying override_options as a class decorator - #126960

Merged
hobzcalvin merged 1 commit into
masterfrom
fix-override-options-class-decorator
Oct 9, 2026
Merged

hobzcalvin merged 1 commit into
masterfrom
fix-override-options-class-decorator

Conversation

@hobzcalvin

@hobzcalvin hobzcalvin commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

override_options is a @contextmanager, so using it as a class decorator replaces the TestCase with a plain function and pytest silently stops collecting it. Three classes on master were affected and had never been running (42 tests collected across these two files before this change, 74 after).

Their option overrides now live on the test methods or in an autouse fixture. Once the classes were collected again, three tests failed because they had drifted:

  • TestVSTSNewOAuth2CallbackView asserted prompt=consent on the token exchange. 🔧 chore: remove consent prompt from azure devops auth flow #87794 moved that to the authorize URL in VSTSOAuth2LoginView. The exchange test now asserts prompt is never sent, the redundant "without consent" duplicate is gone, and a new TestVSTSOAuth2LoginView covers vsts.consent-prompt on and off.
  • UserDetailsSuperuserUpdateTest.test_superuser_with_permission_can_add_superuser and UserDetailsStaffUpdateTest.test_staff_with_permission_can_add_superuser never set SUPERUSER_ORG_ID after ref: Replace SENTRY_DEFAULT_ORGANIZATION_ID with SUPERUSER_ORG_ID #107774, so user_can_elevate returned False. They now wrap the request in self.settings(SUPERUSER_ORG_ID=org.id) like their sibling tests.

UserDetailsStaffUpdateTest already applied staff.ga-rollout through an autouse fixture, so its decorator is simply removed.

Made with Cursor

override_options is a generator-based context manager, so using it as a class
decorator replaces the TestCase with a function and pytest silently stops
collecting it. Three classes were affected; their tests had drifted:

- TestVSTSNewOAuth2CallbackView asserted prompt=consent on the token exchange,
  which #87794 moved to the authorize URL. Assert the exchange never sends it
  and cover the option on VSTSOAuth2LoginView instead.
- UserDetailsSuperuserUpdateTest and UserDetailsStaffUpdateTest each had one
  test missing SUPERUSER_ORG_ID after #107774.

Co-authored-by: Cursor <cursoragent@cursor.com>
@hobzcalvin
hobzcalvin marked this pull request as ready for review October 8, 2026 21:11
@hobzcalvin
hobzcalvin requested a review from a team as a code owner October 8, 2026 21:11

@giovanni-guidini giovanni-guidini left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🥔🥔

@hobzcalvin
hobzcalvin merged commit 36d92ce into master Oct 9, 2026
66 checks passed
@hobzcalvin
hobzcalvin deleted the fix-override-options-class-decorator branch October 9, 2026 16:54
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.

2 participants