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:
parent
7598ad0b57
commit
40896fc70b
@ -182,8 +182,13 @@ class PillarServer(Eve):
|
||||
def load_extension(self, pillar_extension, url_prefix):
|
||||
from .extension import PillarExtension
|
||||
|
||||
assert isinstance(pillar_extension, PillarExtension), \
|
||||
'Extension has wrong type %r' % type(pillar_extension)
|
||||
if not isinstance(pillar_extension, PillarExtension):
|
||||
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)
|
||||
|
||||
# Remember this extension, and disallow duplicates.
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import base64
|
||||
@ -94,9 +96,15 @@ class AbstractPillarTest(TestMinimal):
|
||||
|
||||
# Not only delete self.app (like the superclass does),
|
||||
# but also un-import the application.
|
||||
del sys.modules['pillar']
|
||||
remove = [modname for modname in sys.modules
|
||||
if modname.startswith('pillar.')]
|
||||
self.unload_modules('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:
|
||||
del sys.modules[modname]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user