Do not register tests module when pool is not started for testing
Closes #6846
This commit is contained in:
1 parent
fbbd4ac109
commit
defb428339
5 files changed
+12
-10
No files matched your search
@@ -279,7 +279,7 @@ class Module(ModelSQL, ModelView):
|
||||
def update_list(cls):
|
||||
'Update the list of available packages'
|
||||
count = 0
|
||||
module_names = get_module_list()
|
||||
module_names = get_module_list(with_test=Pool.test)
|
||||
|
||||
modules = cls.search([])
|
||||
name2id = dict((m.name, m.id) for m in modules)
|
||||
|
||||
@@ -223,7 +223,7 @@ class View(ModelSQL, ModelView):
|
||||
def _module_index(self):
|
||||
from trytond.modules import create_graph, get_module_list
|
||||
if self.__class__.__module_index is None:
|
||||
graph = create_graph(get_module_list())
|
||||
graph = create_graph(get_module_list(with_test=Pool.test))
|
||||
modules = [m.name for m in graph]
|
||||
self.__class__.__module_index = {
|
||||
m: i for i, m in enumerate(reversed(modules))}
|
||||
|
||||
@@ -318,7 +318,7 @@ def load_module_graph(graph, pool, update=None, lang=None):
|
||||
logger.info('all modules loaded')
|
||||
|
||||
|
||||
def get_module_list():
|
||||
def get_module_list(with_test=False):
|
||||
module_list = set()
|
||||
if os.path.exists(MODULES_PATH) and os.path.isdir(MODULES_PATH):
|
||||
for file in os.listdir(MODULES_PATH):
|
||||
@@ -332,11 +332,12 @@ def get_module_list():
|
||||
module_list.update(EGG_MODULES.keys())
|
||||
module_list.add('ir')
|
||||
module_list.add('res')
|
||||
module_list.add('tests')
|
||||
if with_test:
|
||||
module_list.add('tests')
|
||||
return list(module_list)
|
||||
|
||||
|
||||
def register_classes():
|
||||
def register_classes(with_test=False):
|
||||
'''
|
||||
Import modules to register the classes in the Pool
|
||||
'''
|
||||
@@ -344,10 +345,11 @@ def register_classes():
|
||||
trytond.ir.register()
|
||||
import trytond.res
|
||||
trytond.res.register()
|
||||
import trytond.tests
|
||||
trytond.tests.register()
|
||||
if with_test:
|
||||
import trytond.tests
|
||||
trytond.tests.register()
|
||||
|
||||
for node in create_graph(get_module_list()):
|
||||
for node in create_graph(get_module_list(with_test=with_test)):
|
||||
module = node.name
|
||||
logger.info('%s:registering classes', module)
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ class Pool(object):
|
||||
with cls._lock:
|
||||
for classes in Pool.classes.values():
|
||||
classes.clear()
|
||||
register_classes()
|
||||
register_classes(with_test=cls.test)
|
||||
cls._started = True
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -51,6 +51,7 @@ __all__ = [
|
||||
'with_transaction',
|
||||
]
|
||||
|
||||
Pool.test = True
|
||||
Pool.start()
|
||||
USER = 1
|
||||
CONTEXT = {}
|
||||
@@ -62,7 +63,6 @@ else:
|
||||
DB_NAME = 'test_' + str(int(time.time()))
|
||||
os.environ['DB_NAME'] = DB_NAME
|
||||
DB_CACHE = os.environ.get('DB_CACHE')
|
||||
Pool.test = True
|
||||
|
||||
|
||||
def activate_module(modules, lang='en'):
|
||||
|
||||
Reference in new issue
Block a user