From 17d46b7317079bae50085da9e9d100ff1f769f91 Mon Sep 17 00:00:00 2001 From: dgw Date: Wed, 9 Oct 2024 02:34:39 -0500 Subject: [PATCH] pytest_plugin: disable flood protection for example tests For quite a while, we've had three tests from the `rand` plugin that take several seconds each. I had a Sopelunk with the Git version [1] of `pytest-profiling` [2] and discovered that about 98% of the time spent on the five tests selected by `pytest -k rand.py` was in `time.sleep()`. Drilling down, I saw that was being called from `bot.say()`, which led pretty quickly to the real culprit: Flood protection. There's no server to flood during tests, so we can just turn that protection off. With this change, those five tests from `rand` went from about 12 seconds on my test system down to about 0.25 sec. [1]: The last actual release of `pytest-profiling` is from 2019, and it doesn't work on modern Python. (I started analyzing this under Python 3.13, while verifying fixes for new warnings there.) All of the necessary updates already exist in the Git repo, though; they just haven't published a new release in five years. [2]: https://github.com/man-group/pytest-plugins/tree/master/pytest-profiling --- sopel/tests/pytest_plugin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sopel/tests/pytest_plugin.py b/sopel/tests/pytest_plugin.py index 16a58c07a..2208a0d1c 100644 --- a/sopel/tests/pytest_plugin.py +++ b/sopel/tests/pytest_plugin.py @@ -18,6 +18,8 @@ nick = {name} owner = {owner} admin = {admin} +# avoid wasting cycles in time.sleep() during `repeat`ed tests +flood_max_wait = 0 """