diff --git a/pyblish/plugin.py b/pyblish/plugin.py index e6636a9..f5589e2 100644 --- a/pyblish/plugin.py +++ b/pyblish/plugin.py @@ -770,8 +770,7 @@ def create_instance(self, name, **kwargs): """ - instance = Instance(name, parent=self) - instance.data.update(kwargs) + instance = Instance(name, parent=self, **kwargs) return instance def __getitem__(self, item): @@ -820,10 +819,11 @@ class Instance(AbstractEntity): """ - def __init__(self, name, parent=None): + def __init__(self, name, parent=None, **kwargs): super(Instance, self).__init__(name, parent) self._data["family"] = "default" self._data["name"] = name + self._data.update(kwargs) def __eq__(self, other): return self._id == getattr(other, "id", None) diff --git a/pyblish/version.py b/pyblish/version.py index 1b7c1ec..ad774a8 100644 --- a/pyblish/version.py +++ b/pyblish/version.py @@ -1,7 +1,7 @@ VERSION_MAJOR = 1 VERSION_MINOR = 8 -VERSION_PATCH = 8 +VERSION_PATCH = 9 version_info = (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH) version = '%i.%i.%i' % version_info diff --git a/tests/test_plugin.py b/tests/test_plugin.py index f67e9d2..3e09373 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -651,6 +651,14 @@ def process(self, context): assert count["#"] == 11, count +def test_instance_kwarg_init(): + # check if all kwargs get passed to the metadata dict of the instance + mock_families = ['mock_family1', 'mock_family2'] + inst = pyblish.api.Instance(name='test', madeup_kwarg=13, families=mock_families) + assert inst.data['madeup_kwarg'] == 13 + assert inst.data['families'] == mock_families + + def test_actions_and_explicit_plugins(): """Actions work with explicit plug-ins"""