def METHOD_NAME(plugin, plugin_version, add_module_to_sys=True, add_version=True):
    import sys
    import types
    import uuid
    # Create a new module with a unique name and add the `plugin` and `plugin_version` as attributes
    module_name = f'TestModule{str(uuid.uuid4())[:5]}'
    dynamic_module = types.ModuleType(module_name, 'Dynamically created module for testing purposes')
    setattr(plugin, '__module__', dynamic_module.__name__)  # pylint: disable=no-member
    setattr(dynamic_module, plugin.__name__, plugin)
    # For tests that need to fail, this flag can be set to `False`
    if add_version:
        setattr(dynamic_module, '__version__', plugin_version)
    # Get the `DummyClass` plugin from the dynamically created test module
    dynamic_plugin = getattr(dynamic_module, plugin.__name__)
    # Make the dynamic module importable unless the test requests not to, to test an unimportable module
    if add_module_to_sys:
        sys.modules[dynamic_module.__name__] = dynamic_module  # pylint: disable=no-member
    return dynamic_plugin