pony
pony copied to clipboard
pony orm and pytest
Hay thanks for the great orm mapper. I have a issue using it within pytest. If I run the test first time everything is fine and works perfectly. After run the same couple of test again I got
pony.orm.core.BindingError: Database object was already bound to PostgreSQL provider
It seems that the state of the connection/session is saved beyond the process livetime of pytest. Currently I always have to restart the database to kill this established session....
Is there something wrong at Ponyorm or have you a hint how this behavior can be resolved?
Thanks in advance, Thomas
Hello.
It means you use db.bind
twice or more in your code.
You can recreate Database
instance for each test.
I do multiple Database instances and I get the already bind error. It is possible to check if it is already bind to avoid this issue?
Yes, something like this
def is_bound(db):
return db.provider is not None