_core.py 813 B

12345678910111213141516171819202122232425
  1. import threading
  2. from six import with_metaclass
  3. from pluggy import PluginManager
  4. from allure_commons import _hooks
  5. class MetaPluginManager(type):
  6. _storage = threading.local()
  7. @staticmethod
  8. def get_plugin_manager():
  9. if not hasattr(MetaPluginManager._storage, 'plugin_manager'):
  10. MetaPluginManager._storage.plugin_manager = PluginManager('allure')
  11. MetaPluginManager._storage.plugin_manager.add_hookspecs(_hooks.AllureUserHooks)
  12. MetaPluginManager._storage.plugin_manager.add_hookspecs(_hooks.AllureDeveloperHooks)
  13. return MetaPluginManager._storage.plugin_manager
  14. def __getattr__(cls, attr):
  15. pm = MetaPluginManager.get_plugin_manager()
  16. return getattr(pm, attr)
  17. class plugin_manager(with_metaclass(MetaPluginManager)):
  18. pass