This workload seems IO bound so python 3.11 shouldn't add too many speedups here, it adds mostly cpu-bound improvements. Surprised you are getting speedsup - any idea which parts?
It is I/O bound but it's all localized. Those URL endpoints aren't making external API calls. For tests, Postgres is set to use Session.begin_nested with SQLAlchemy which takes advantage of Postgres' ability to use SQL SAVEPOINTs[0]. The gory details are above my paygrade (I found it while Googling), but the end result is it makes Postgres able to be really really fast when accessing your DB in tests. I don't think it really writes to disk but it makes your app think it did and you get the "true" outcome of running the SQL (ids get created, all of your SQL works as expected, etc.). It's not a mock.
[0]: https://docs.sqlalchemy.org/en/20/orm/session_transaction.ht...