def plugins_context(classes, category=None):
    """ context manager to load plugin class(es) then unload on exit

    Parameters
    ----------
    classes: list
        list of classes
    category : None or str
        if str, apply for single plugin category

    Examples
    --------
    >>> from pprint import pprint

    >>> class DecoderPlugin(object):
    ...     plugin_name = 'example'
    ...     plugin_descript = 'a decoder for dicts containing _example_ key'
    ...     dict_signature = ('_example_',)
    ...

    >>> with plugins_context([DecoderPlugin]):
    ...     pprint(view_plugins())
    {'decoders': {'example': 'a decoder for dicts containing _example_ key'},
     'encoders': {},
     'parsers': {}}

    >>> pprint(view_plugins())
    {'decoders': {}, 'encoders': {}, 'parsers': {}}


    """
    original = {cat: list(_all_plugins[cat].keys()) for cat in _all_plugins}
    load_plugin_classes(classes, category, overwrite=True)
    # if errors:
    #     for cat in _all_plugins:
    #         for name, kls in list(_all_plugins[cat].items()):
    #             if name not in original[cat]:
    #                 _all_plugins[cat].pop(name)
    #     raise RuntimeError(
    # "errors occurred while loading plugins: {}".format(errors))
    yield
    for cat in _all_plugins:
        for name, kls in list(_all_plugins[cat].items()):
            if name not in original[cat]:
                _all_plugins[cat].pop(name)
context manager to load plugin class(es) then unload on exit

    Parameters
    ----------
    classes: list
        list of classes
    category : None or str
        if str, apply for single plugin category

    Examples
    --------
    >>> from pprint import pprint

    >>> class DecoderPlugin(object):
    ...     plugin_name = 'example'
    ...     plugin_descript = 'a decoder for dicts containing _example_ key'
    ...     dict_signature = ('_example_',)
    ...

    >>> with plugins_context([DecoderPlugin]):
    ...     pprint(view_plugins())
    {'decoders': {'example': 'a decoder for dicts containing _example_ key'},
     'encoders': {},
     'parsers': {}}

    >>> pprint(view_plugins())
    {'decoders': {}, 'encoders': {}, 'parsers': {}}