Coming from a Ruby on Rails background, I appreciate solutions that become community standards of solving problems. One example is DatabaseCleaner, which ensures that your software projects tests run in separation and there are no data leaks between them.
Recently, I was looking for a similar solution for Python, but was unable to find one. However, it’s easy to leverage what SQLAlchemy and Pytest offer to wrap tests in separate database transactions. Below you will find a take on the problem that you may find convenient to use.