-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
Like others (here and here), I was surprised with the new warnings in pytest 7.2 when test functions return values other than None. Dating since the original issue (#7337), there was quite a bit of debate about whether this was a good idea.
Personally, making something raise an exception not because it's an error, but simply because some users may get confused by it, feels somewhat inconsistent with other decisions made in Python. For example, these Python "gotchas" could raise exceptions, but don't, because sometimes you do actually mean to do these things -- as is the case with returning non-None from a test.
I'd propose to (a) keep the warning, but leave it as a warning indefinitely (so filterwarnings can be used), and/or (b) add a config flag under the pytest-warnings section for --allow-return-not-none.