Example code for stackoverflow question 58270958 showing how to spy on BackgroundTasks.add_task(...)
with pytest.
git clone https://gist.github.com/dcba361f7b5cd6aba636e5c8a4b1aad6.git
cd dcba361f7b5cd6aba636e5c8a4b1aad6
pipenv install
pipenv run pytest