Better logging when bad extension class is given.
This was necessary to debug an issue with different unit tests influencing each other in Attract.
This commit is contained in:
@@ -182,8 +182,13 @@ class PillarServer(Eve):
|
|||||||
def load_extension(self, pillar_extension, url_prefix):
|
def load_extension(self, pillar_extension, url_prefix):
|
||||||
from .extension import PillarExtension
|
from .extension import PillarExtension
|
||||||
|
|
||||||
assert isinstance(pillar_extension, PillarExtension), \
|
if not isinstance(pillar_extension, PillarExtension):
|
||||||
'Extension has wrong type %r' % type(pillar_extension)
|
if self.config.get('DEBUG'):
|
||||||
|
for cls in type(pillar_extension).mro():
|
||||||
|
self.log.error('class %42r (%i) is %42r (%i): %s',
|
||||||
|
cls, id(cls), PillarExtension, id(PillarExtension),
|
||||||
|
cls is PillarExtension)
|
||||||
|
raise AssertionError('Extension has wrong type %r' % type(pillar_extension))
|
||||||
self.log.info('Loading extension %s', pillar_extension.name)
|
self.log.info('Loading extension %s', pillar_extension.name)
|
||||||
|
|
||||||
# Remember this extension, and disallow duplicates.
|
# Remember this extension, and disallow duplicates.
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
@@ -94,9 +96,15 @@ class AbstractPillarTest(TestMinimal):
|
|||||||
|
|
||||||
# Not only delete self.app (like the superclass does),
|
# Not only delete self.app (like the superclass does),
|
||||||
# but also un-import the application.
|
# but also un-import the application.
|
||||||
del sys.modules['pillar']
|
self.unload_modules('pillar')
|
||||||
remove = [modname for modname in sys.modules
|
|
||||||
if modname.startswith('pillar.')]
|
def unload_modules(self, module_name):
|
||||||
|
"""Uploads the named module, and all submodules."""
|
||||||
|
|
||||||
|
del sys.modules[module_name]
|
||||||
|
|
||||||
|
remove = {modname for modname in sys.modules
|
||||||
|
if modname.startswith('%s.' % module_name)}
|
||||||
for modname in remove:
|
for modname in remove:
|
||||||
del sys.modules[modname]
|
del sys.modules[modname]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user