Ah, no I remember something: Can you apply this to your project?
i.e
extra_scripts = post:extra_script.py
in the platformio.ini and a new file extra_script.py on the same level as the platformio.ini with
import time
Import("env")
if "test" in env.GetBuildType():
env.AddPostAction("upload", lambda *_, **__: time.sleep(2))