details: https://code.tryton.org/tryton/commit/e9f2b42e96eb
branch: default
user: Nicolas Évrard <[email protected]>
date: Mon Aug 10 14:51:04 2026 +0200
description:
Reset TABLES_CREATED when dropping the database when testing
Closes #15002
diffstat:
trytond/trytond/model/modelsql.py | 27 +++++++++++++++------------
trytond/trytond/tests/__init__.py | 2 ++
trytond/trytond/tests/test_tryton.py | 3 +++
3 files changed, 20 insertions(+), 12 deletions(-)
diffs (79 lines):
diff -r 9711708ebcd6 -r e9f2b42e96eb trytond/trytond/model/modelsql.py
--- a/trytond/trytond/model/modelsql.py Wed Aug 05 17:39:38 2026 +0200
+++ b/trytond/trytond/model/modelsql.py Mon Aug 10 14:51:04 2026 +0200
@@ -302,7 +302,6 @@
return lambda col: NullOrdering(Order(col))
-_TABLES_CREATED = set()
_TABLE_QUERY_COLUMNS = {
'create_uid': Literal(0),
'create_date': CurrentTimestamp(),
@@ -509,20 +508,24 @@
# create/update table in the database
table = cls.__table_handler__(module_name)
- if Pool.test and cls._table not in _TABLES_CREATED:
- database.setnextid(
- transaction.connection, cls._table,
- len(_TABLES_CREATED) * 500 + 1)
- _TABLES_CREATED.add(cls._table)
+ if Pool.test:
+ from trytond.tests import TABLES_CREATED
+ if cls._table not in TABLES_CREATED:
+ database.setnextid(
+ transaction.connection, cls._table,
+ len(TABLES_CREATED) * 500 + 1)
+ TABLES_CREATED.add(cls._table)
if cls._history:
history_table = cls.__table_handler__(module_name, history=True)
- table_history = f'{cls._table}__history'
- if Pool.test and table_history not in _TABLES_CREATED:
- database.setnextid(
- transaction.connection, table_history,
- len(_TABLES_CREATED) * 500 + 1)
- _TABLES_CREATED.add(table_history)
+ if Pool.test:
+ from trytond.tests import TABLES_CREATED
+ table_history = f'{cls._table}__history'
+ if table_history not in TABLES_CREATED:
+ database.setnextid(
+ transaction.connection, table_history,
+ len(TABLES_CREATED) * 500 + 1)
+ TABLES_CREATED.add(table_history)
for field_name, field in cls._fields.items():
if field_name == 'id':
diff -r 9711708ebcd6 -r e9f2b42e96eb trytond/trytond/tests/__init__.py
--- a/trytond/trytond/tests/__init__.py Wed Aug 05 17:39:38 2026 +0200
+++ b/trytond/trytond/tests/__init__.py Mon Aug 10 14:51:04 2026 +0200
@@ -3,6 +3,8 @@
from importlib.metadata import entry_points
+TABLES_CREATED = set()
+
def register():
from . import (
diff -r 9711708ebcd6 -r e9f2b42e96eb trytond/trytond/tests/test_tryton.py
--- a/trytond/trytond/tests/test_tryton.py Wed Aug 05 17:39:38 2026 +0200
+++ b/trytond/trytond/tests/test_tryton.py Mon Aug 10 14:51:04 2026 +0200
@@ -42,6 +42,8 @@
from trytond.wizard import StateAction, StateView
from trytond.wsgi import app
+from . import TABLES_CREATED as _TABLES_CREATED
+
__all__ = [
'CONTEXT',
'Client',
@@ -1348,6 +1350,7 @@
database.drop(transaction.connection, name)
Pool.stop(name)
Cache.drop(name)
+ _TABLES_CREATED.clear()
def drop_create(name=DB_NAME, lang='en'):