Tootfinder

Opt-in global Mastodon full text search. Join the index!

@mgorny@social.treehouse.systems
2024-04-02 15:35:40

Recently I've added a cheap hack to the standard #Gentoo invocation for #PyTest to throw errors if unhandled async functions are detected. The goal was to increase our chances of finding packages with missing dependency on dev-python/pytest-asyncio (or another equivalent plugin), or packages disabling plugin autoloading and failing to load such a plugin.
Today, I've gotten a first bug report, regarding dev-python/ipython. I've grepped the sources and confirmed that the package depends on PyTest-AsyncIO, except that it pins to < 0.22. Well, we don't have one that old but let's hope it works anyway. So I've tried adding the dep, `-p asyncio`… and PyTest still apparently couldn't find the plugin. I've scratched my head and tried `PYTEST_PLUGINS` instead — still the same result. What the…?
So I've checked the git repository out, tried with older PyTest-AsyncIO, and indeed the tests worked. Tried with the newest, 0.23.6, and the same issue occurred. I've checked the git history and discovered that the version pin was added because of a buggy 0.22.0 release. However, the issue has been fixed since, the release was yanked and my problem was nothing like that.
So I've investigated more. For some reason, #IPython test suite does not mark tests with `pytest.mark.asyncio` marker directly. Instead, it globally iterates over all test functions, and implicitly adds the marker to all coroutines. This used to work with older versions, but does not work anymore — the test is correctly marked, but for some reason it stops being recognized as a coroutine. So I've made a minimal reproducer and filed a bug.
The key point here is: the (potential) bug went unnoticed for a while now, because of the premature, then obsolete pin in IPython.
#Python