Skip to content

make async tests and tests that return non-None fail instead of warn #12346

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

Merged
merged 6 commits into from
Oct 25, 2024

Conversation

polkapolka
Copy link
Contributor

No description provided.

Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

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

👋 Hi Phebe! This looks good to me overall - three things to do:

  1. Moving the exception definition, as below
  2. Doing the various TODOs in comments
  3. Edit the top comment to link to the issue for awareness and auto-closing, and briefly describe the issue.

@nicoddemus
Copy link
Member

Hi folks,

Sorry why is this being done? Is there an issue related to it?

@Zac-HD
Copy link
Member

Zac-HD commented May 22, 2024

Suggested in #11372 🙂

(and we're at the PyCon US sprints, so most communication about this has been verbal instead of online)

@nicoddemus
Copy link
Member

Ahh OK, no worries, thanks @Zac-HD!

If possible it helps adding the issue number in the PR description for context. 👍

@jakkdl jakkdl linked an issue Oct 23, 2024 that may be closed by this pull request
…. Make tests fail instead of raising warning/exception. fix tests. add changelog.
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Oct 25, 2024
@jakkdl
Copy link
Member

jakkdl commented Oct 25, 2024

Did an overhaul of the implementation, I don't think creating exceptions in _pytest.config.exceptions is the best way of doing this, it seems more in line with other stuff to do fail(msg, pytrace=False) instead. The TODOs in unittest.py are not applicable for this PR, since they were testing stuff with async plugin installed.
test_function_return_not_none_warning weren't actually testing if a warning was raised... but it now checks for fail outcome.

I also implemented ReturnNotNone, because it felt minimal and similar enough to just get done. Couldn't find an issue to link the newsfragment to though so I just pointed it to this PR.

codecov seems somewhat confused, but afaict everything is actually fine.

@jakkdl jakkdl changed the title changed warning raised by async def to error make async tests and tests that return non-None fail instead of warn Oct 25, 2024
@jakkdl jakkdl requested review from graingert and Zac-HD October 25, 2024 13:07
Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

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

Thanks @polkapolka and @jakkdl for your work on this! I'm looking forward to using it myself 😁

@Zac-HD Zac-HD merged commit 5d3a3ac into pytest-dev:main Oct 25, 2024
29 checks passed
@@ -0,0 +1 @@
Async tests will now fail, instead of warning+skipping, if you don't have any suitable plugin installed.
Copy link
Member

Choose a reason for hiding this comment

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

Traditionally we have marked changelog entries that turned warnings into errors as breaking, to stand out more.

Copy link
Member

Choose a reason for hiding this comment

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

good to know, feel free to rename the file :)

Copy link
Member

Choose a reason for hiding this comment

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

Done in #12942.

nicoddemus added a commit that referenced this pull request Nov 6, 2024
Follow up to #12346.
nicoddemus added a commit that referenced this pull request Nov 6, 2024
Follow up to #12346.
jakkdl pushed a commit to jakkdl/pytest that referenced this pull request Nov 11, 2024
Glyphack pushed a commit to Glyphack/pytest that referenced this pull request Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided (automation) changelog entry is part of PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pytest does not notify users when async tests are ignored
5 participants