Random test failure for account module with SQLite backend
Ex:
- https://foss.heptapod.net/tryton/tryton/-/jobs/2805256
- https://foss.heptapod.net/tryton/tryton/-/jobs/2805259
- https://foss.heptapod.net/tryton/tryton/-/jobs/2805260
It seems to happen since 095c833cfde5 the upgrade to the universal chart of account which contains more accounts. I suspect that this happens because we rely on database suppression on implicit cleaning of the connection. To keep the SQLite database in memory, the SQLite backend keep a reference to the unique SQLite connection. And when the database is dropped we just remove the reference and rely on Python garbage collector to close the connection by deleting the object. But I think that when the OS is quite busy, Python GC does not delete fast enough and the tests may already create a new connection to the SQLite database in memory which prevent the actual cleaning of the database. The result is that we have 2 times the chart of account created in the database which fails the tests.
I think the solution is to actually close the SQLite connection when the database has been dropped.