The way the patch decorator was being used is not supported in python 3.11. Use the patch decorator to auto generate the correct mock and make the test a bit more readabale. The new change is both 3.8 and 3.11 compatible.
toggle_warnings
toggle_warning