-
Notifications
You must be signed in to change notification settings - Fork 20
Description
Describe the bug
After running tests using create_postgres_fixture
, the created databases and templates are not removed upon completion. This leads to the buildup of old entries in an existing database at best and at worst causes errors if you try to change the configuration (due to existing old databases). I think after the test concludes (before the engine is finally disposed) it should clean up the templates and mock databases it created. At the very least, this behavior should be toggleable.
Environment
- Host OS - MacOS
- Docker image if applicable
- Python Version - 3.12
To Reproduce
Steps to reproduce the behavior:
- Create and run a test using
create_postgres_fixture
using an existing running docker postgres database. Do this multiple times. - Change the setting "template_database" to False
- Run your test, this time it will fail because of an existing database
- Change the setting "template_database" back to True
- Your tests will again fail because of an existing database
- Connect to the existing database using
psql
- List the databases and see a multiple
pytest_mock_resource_db_
databases.
Expected behavior
After running tests using an existing docker container, there should not be any remaining databases. Moreover, changing template_database
back to True should not still fail.
Actual Behavior
Every test run creates new databases and they persist. Changing template_database
back to True after running a Test with it at False causes a database already exists error.
Additional context
This problem only exists if you use an existing docker database instead of one generated by pytest mock resources.