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

Mark MockHttp as not for collection by pytest #2014

Conversation

s-t-e-v-e-n-k
Copy link

Mark MockHttp as not for collection by pytest

Description

pytest 8.2.0 contains a regression that will collect non-test classes, so as to be explicit about it, mark MockHttp (and therefore all of its children classes) as not to be collected.

pytest regression has been filed upstream as pytest-dev/pytest#12425.

After this merges, pdm can upgrade pytest to 8.2.x.

Status

Done, ready for review.

Checklist (tick everything that applies)

  • Code linting (required, can be done after the PR checks)
  • Documentation
  • Tests
  • ICLA (required for bigger changes)

pytest 8.2.0 contains a regression that will collect non-test classes,
so as to be explicit about it, mark MockHttp (and therefore all of its
children classes) as not to be collected.
@@ -97,6 +97,8 @@ class MockHttp(LibcloudConnection):

(int status, str body, dict headers, str reason)
"""
# pytest may collect this class, and we don't need or want that
__test__ = False

Choose a reason for hiding this comment

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

this hides tests that use a broken inheritance tree

Copy link
Author

Choose a reason for hiding this comment

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

Can we determine which tests those are? I'm happy to fix them, because otherwise pytest 8.2 collects the class and can not instantiate it.

Choose a reason for hiding this comment

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

I linked one in the upstream bug, at first glance it's not fixable

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the contribution.

As @RonnyPfannschmidt pointed out, that will break a bunch of tests which have assertions directly in subclassed MockHttp class (I believe there are quite a few of those).


On a related note, pytest 8.0.x also broke a bunch of other tests recently due to the changes in the test loading / discovery mechanism (#1994). I battle for quite a while to get everything to pass.

Granted, in that specific case, one of the main issues was cross test pollution. Tests would only fail when they ran in a very specific order and that's why we didn't detect that issue earlier and it was hard to track down and fix.

@s-t-e-v-e-n-k
Copy link
Author

Closing as a terrible idea.

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