Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conftest: put transaction manager in its own fixture #16796

Merged
merged 6 commits into from
Oct 2, 2024

Conversation

woodruffw
Copy link
Member

This moves the tm local from the webtest fixture into its own fixture.

This should have no impact on its own, but it will hopefully make it easier to tease apart whatever session/TM mismatch is causing CI failures like https://github.com/pypi/warehouse/actions/runs/11057423074/job/30721387457?pr=16778.

See: #15634 (comment)

@woodruffw woodruffw requested a review from a team as a code owner September 26, 2024 21:48
Signed-off-by: William Woodruff <[email protected]>
@woodruffw woodruffw self-assigned this Sep 26, 2024
@woodruffw woodruffw added the testing Test infrastructure and individual tests label Sep 26, 2024
@di di enabled auto-merge (squash) September 27, 2024 00:22
@di
Copy link
Member

di commented Sep 27, 2024

@woodruffw Looks like this breaks some tests (probably because it's session-scoped).

@di di disabled auto-merge September 27, 2024 00:29
tests/conftest.py Outdated Show resolved Hide resolved
@woodruffw
Copy link
Member Author

@woodruffw Looks like this breaks some tests (probably because it's session-scoped).

Whoops, fixed!

Copy link
Member

@miketheman miketheman left a comment

Choose a reason for hiding this comment

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

I'm 👍 generally, but I'm curious about the timing of this - since the tm.begin()/tm.doom() calls now happen after get_db_session_for_app_config() is called - does that change the behavior at all?

@woodruffw
Copy link
Member Author

woodruffw commented Oct 1, 2024

I'm 👍 generally, but I'm curious about the timing of this - since the tm.begin()/tm.doom() calls now happen after get_db_session_for_app_config() is called - does that change the behavior at all?

I might not be following, but I think the order is correct here -- if my understanding of pytest fixture scoping is correct, the ordering here should be:

database (session-scoped)
  app_config_dbsession_from_end (session-scoped)
    tm (function-scoped)
      get_db_session_for_app_config -> _db_session (context manager within function scope)
        actual test code

But it's possible I'm missing where the scope has changed 🙂

@miketheman
Copy link
Member

Maybe I didn't phrase the question well?
It's specifically that currently, tm.begin()/tm.doom() are explicitly called prior to calling get_db_session_for_app_config and creating the TestApp, and with this change, the call to begin/doom happens later.

I don't think it will matter, so let's ship this and find out.

@miketheman miketheman merged commit dc5b0e4 into pypi:main Oct 2, 2024
18 checks passed
@miketheman miketheman deleted the ww/tm-fixture branch October 2, 2024 15:27
@woodruffw
Copy link
Member Author

It's specifically that currently, tm.begin()/tm.doom() are explicitly called prior to calling get_db_session_for_app_config and creating the TestApp, and with this change, the call to begin/doom happens later.

Ah, I see what you mesn! Yeah, I think that won't matter, but that is indeed a slight difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Test infrastructure and individual tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants