[Zope3-checkins]
SVN: zope.testing/branches/3.5/src/zope/testing/testrunner.py
Provide better diagnostics when layer_from_name() fails.
Marius Gedminas
marius at pov.lt
Fri Aug 1 08:30:26 EDT 2008
Log message for revision 89132:
Provide better diagnostics when layer_from_name() fails.
Backported r89123 from trunk.
Changed:
U zope.testing/branches/3.5/src/zope/testing/testrunner.py
-=-
Modified: zope.testing/branches/3.5/src/zope/testing/testrunner.py
===================================================================
--- zope.testing/branches/3.5/src/zope/testing/testrunner.py 2008-08-01 12:28:59 UTC (rev 89131)
+++ zope.testing/branches/3.5/src/zope/testing/testrunner.py 2008-08-01 12:30:25 UTC (rev 89132)
@@ -1564,7 +1564,16 @@
return _layer_name_cache[layer_name]
layer_names = layer_name.split('.')
layer_module, module_layer_name = layer_names[:-1], layer_names[-1]
- return getattr(import_name('.'.join(layer_module)), module_layer_name)
+ module_name = '.'.join(layer_module)
+ module = import_name(module_name)
+ try:
+ return getattr(module, module_layer_name)
+ except AttributeError, e:
+ # the default error is very uninformative:
+ # AttributeError: 'module' object has no attribute 'DemoLayer'
+ # it doesn't say *which* module
+ raise AttributeError('module %r has no attribute %r'
+ % (module_name, module_layer_name))
def order_by_bases(layers):
"""Order the layers from least to most specific (bottom to top)
More information about the Zope3-Checkins
mailing list