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

Pytest Tweaks, Part III - Test Isolation #277

Merged
merged 5 commits into from
Nov 30, 2024
Merged

Conversation

hatchet-temporary
Copy link
Contributor

@hatchet-temporary hatchet-temporary commented Nov 30, 2024

Reworking the bg_worker fixture to:

  1. Not be autoused (it needs to be requested now)
  2. Be torn down after each test function
  3. Not need to be manually instantiated (we can pass the example name as a param)

I was seeing some weird failures in CI that were indicating that there was leakage between the tests, and this seemed like a pretty obvious possible culprit. I think what was happening was the fixtures were being spun up but not torn down, so if (e.g.) two workflows had the same name, that could cause problems

@pytest.mark.skip(reason="The timing for this test is not reliable")
@pytest.mark.asyncio(scope="session")
async def test_run(aiohatchet: Hatchet):
async def test_run(aiohatchet: Hatchet, worker):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we have to explicitly request the fixture now



# requires scope module or higher for shared event loop
@pytest.mark.parametrize("worker", ["concurrency_limit_rr"], indirect=True)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

parametrizing the fixture with the example to run

@hatchet-temporary hatchet-temporary merged commit 26764a3 into main Nov 30, 2024
5 checks passed
@hatchet-temporary hatchet-temporary deleted the pytest-pt-3 branch November 30, 2024 20:57
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