Skip to content

Commit e807db4

Browse files
committed
During tests, Keep wizards on memory and avoid autosync
1 parent 1edfe8e commit e807db4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

destral/openerp.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ def __init__(self, **kwargs):
4949
self.pool = None # type: Optional[osv_pool]
5050
self.cursor_stack = _cursor_context
5151
self.ws_stack = _ws_info
52+
53+
try:
54+
from ctx import _wizard_changes_stack
55+
self.wizard_stack = _wizard_changes_stack
56+
from tools.service_utils import KeepWizardsSync
57+
self.wizard_sync = KeepWizardsSync(auto_sync=False)
58+
self.wizard_stack.push(self.wizard_sync)
59+
except ImportError:
60+
self.wizard_stack = None
61+
self.wizard_sync = None
62+
5263
if 'db_name' in config:
5364
try:
5465
self.db_name = config['db_name']
@@ -60,6 +71,14 @@ def __init__(self, **kwargs):
6071
# Stop the cron
6172
netsvc.Agent.quit()
6273

74+
def __del__(self):
75+
try:
76+
if self.wizard_stack:
77+
self.wizard_stack.pop()
78+
self.wizard_sync = None
79+
except Exception:
80+
pass
81+
6382
def create_database(self, template=True, db_name=None):
6483
"""Creates a new database.
6584

0 commit comments

Comments
 (0)