From b18c68fa4c17f2814709ef389500b901900e8f4c Mon Sep 17 00:00:00 2001 From: Jeremy Retailleau Date: Sun, 8 Mar 2020 18:29:26 -0700 Subject: [PATCH 01/12] Add targets option to explicitly pass targets to iterator --- pyblish/logic.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyblish/logic.py b/pyblish/logic.py index 8107c669..890ef0b3 100644 --- a/pyblish/logic.py +++ b/pyblish/logic.py @@ -334,7 +334,7 @@ def _extract_traceback(exception): del(exc_type, exc_value, exc_traceback) -def Iterator(plugins, context, state=None): +def Iterator(plugins, context, state=None, targets=None): """Primary iterator This is the brains of publishing. It handles logic related @@ -345,6 +345,7 @@ def Iterator(plugins, context, state=None): plugins (list): Plug-ins to consider context (list): Instances to consider state (dict): Mutable state + targets (list, optional): Targets to include for publish session. """ @@ -356,7 +357,7 @@ def Iterator(plugins, context, state=None): # We'll add "default" target if no targets are registered. This happens # when running the Iterator directly without registering any targets. - targets = registered_targets() or ["default"] + targets = targets or registered_targets() or ["default"] plugins = plugins_by_targets(plugins, targets) From 41568a0c4045d5cb83f96847c7d20f7d91b04246 Mon Sep 17 00:00:00 2001 From: Jeremy Retailleau Date: Sun, 8 Mar 2020 18:30:53 -0700 Subject: [PATCH 02/12] Update logic to pass explicit targets to Iterator instead of registering them --- pyblish/util.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/pyblish/util.py b/pyblish/util.py index aa154291..1e0890b2 100644 --- a/pyblish/util.py +++ b/pyblish/util.py @@ -94,9 +94,6 @@ def publish_iter(context=None, plugins=None, targets=None): def _convenience_iter(context=None, plugins=None, targets=None, order=None): - # Include "default" target when no targets are requested. - targets = targets or ["default"] - # Must check against None, as objects be emptys context = api.Context() if context is None else context plugins = api.discover() if plugins is None else plugins @@ -107,10 +104,6 @@ def _convenience_iter(context=None, plugins=None, targets=None, order=None): if lib.inrange(Plugin.order, order) ) - # Register targets - for target in targets: - api.register_target(target) - # Do not consider inactive plug-ins plugins = list(p for p in plugins if p.active) collectors = list(p for p in plugins if lib.inrange( @@ -123,11 +116,13 @@ def _convenience_iter(context=None, plugins=None, targets=None, order=None): # dynamically determined at run-time by contents of # the context and families of contained instances; # each of which may differ between task. - task_count = len(list(logic.Iterator(plugins, context))) + task_count = len(list(logic.Iterator(plugins, context, targets=targets))) # First pass, collection tasks_processed_count = 1 - for Plugin, instance in logic.Iterator(collectors, context): + for Plugin, instance in logic.Iterator( + collectors, context, targets=targets + ): result = plugin.process(Plugin, context, instance) # Inject additional member for results here. @@ -153,7 +148,9 @@ def _convenience_iter(context=None, plugins=None, targets=None, order=None): } # Second pass, the remainder - for Plugin, instance in logic.Iterator(plugins, context, state): + for Plugin, instance in logic.Iterator( + plugins, context, state, targets=targets + ): try: result = plugin.process(Plugin, context, instance) result["progress"] = ( @@ -184,10 +181,6 @@ def _convenience_iter(context=None, plugins=None, targets=None, order=None): yield result - # Deregister targets - for target in targets: - api.deregister_target(target) - def collect(context=None, plugins=None, targets=None): """Convenience function for collection-only From 4ae275af7092d2fc0295c70cf367c86bad9fabbe Mon Sep 17 00:00:00 2001 From: Jeremy Retailleau Date: Sun, 8 Mar 2020 18:47:20 -0700 Subject: [PATCH 03/12] Update logic to always include 'default' when no targets are explicitly provided --- pyblish/logic.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyblish/logic.py b/pyblish/logic.py index 890ef0b3..792cc204 100644 --- a/pyblish/logic.py +++ b/pyblish/logic.py @@ -355,9 +355,9 @@ def Iterator(plugins, context, state=None, targets=None): "ordersWithError": set() } - # We'll add "default" target if no targets are registered. This happens - # when running the Iterator directly without registering any targets. - targets = targets or registered_targets() or ["default"] + # Include "default" target when no targets are requested. + targets = targets or ["default"] + targets += registered_targets() plugins = plugins_by_targets(plugins, targets) From 7ff224c1559ca0518861701b4abe58987cddb598 Mon Sep 17 00:00:00 2001 From: Jeremy Retailleau Date: Sun, 8 Mar 2020 18:48:56 -0700 Subject: [PATCH 04/12] Fix unit tests Ensure that targets registered for one test does not get used in another. --- tests/lib.py | 10 ++++++++-- tests/pre11/lib.py | 10 ++++++++-- tests/pre11/test_logic.py | 1 + tests/pre13/test_logic.py | 2 ++ tests/test_logic.py | 1 + tests/test_plugin.py | 5 +++++ tests/test_simple.py | 2 ++ tests/test_util.py | 1 + 8 files changed, 28 insertions(+), 4 deletions(-) diff --git a/tests/lib.py b/tests/lib.py index 1982096c..e18e84b4 100644 --- a/tests/lib.py +++ b/tests/lib.py @@ -13,7 +13,8 @@ HOST = 'python' FAMILY = 'test.family' -REGISTERED = pyblish.plugin.registered_paths() +REGISTERED_PATHS = pyblish.plugin.registered_paths() +REGISTERED_TARGETS = pyblish.plugin.registered_targets() PACKAGEPATH = pyblish.lib.main_package_path() ENVIRONMENT = os.environ.get("PYBLISHPLUGINPATH", "") PLUGINPATH = os.path.join(PACKAGEPATH, '..', 'tests', 'plugins') @@ -22,6 +23,7 @@ def setup(): """Disable default plugins and only use test plugins""" pyblish.plugin.deregister_all_paths() + pyblish.plugin.deregister_all_targets() def setup_empty(): @@ -39,9 +41,13 @@ def teardown(): """Restore previously REGISTERED paths""" pyblish.plugin.deregister_all_paths() - for path in REGISTERED: + for path in REGISTERED_PATHS: pyblish.plugin.register_plugin_path(path) + pyblish.plugin.deregister_all_targets() + for target in REGISTERED_TARGETS: + pyblish.plugin.register_target(target) + os.environ["PYBLISHPLUGINPATH"] = ENVIRONMENT pyblish.api.deregister_all_plugins() pyblish.api.deregister_all_hosts() diff --git a/tests/pre11/lib.py b/tests/pre11/lib.py index a1bbb876..6fddf79c 100644 --- a/tests/pre11/lib.py +++ b/tests/pre11/lib.py @@ -7,7 +7,8 @@ HOST = 'python' FAMILY = 'test.family' -REGISTERED = pyblish.plugin.registered_paths() +REGISTERED_PATHS = pyblish.plugin.registered_paths() +REGISTERED_TARGETS = pyblish.plugin.registered_targets() PACKAGEPATH = pyblish.lib.main_package_path() PLUGINPATH = os.path.join(PACKAGEPATH, '..', 'tests', 'pre11', 'plugins') ENVIRONMENT = os.environ.get("PYBLISHPLUGINPATH", "") @@ -16,6 +17,7 @@ def setup(): """Disable default plugins and only use test plugins""" pyblish.plugin.deregister_all_paths() + pyblish.plugin.deregister_all_targets() pyblish.plugin.register_plugin_path(PLUGINPATH) @@ -78,9 +80,13 @@ def teardown(): """Restore previously REGISTERED paths""" pyblish.plugin.deregister_all_paths() - for path in REGISTERED: + for path in REGISTERED_PATHS: pyblish.plugin.register_plugin_path(path) + pyblish.plugin.deregister_all_targets() + for target in REGISTERED_TARGETS: + pyblish.plugin.register_target(target) + os.environ["PYBLISHPLUGINPATH"] = ENVIRONMENT pyblish.api.deregister_all_plugins() diff --git a/tests/pre11/test_logic.py b/tests/pre11/test_logic.py index d031303d..541d62f1 100644 --- a/tests/pre11/test_logic.py +++ b/tests/pre11/test_logic.py @@ -227,6 +227,7 @@ def process_instance(self, instance): assert_equals(_server["assets"][0].metadata, "123") +@with_setup(setup_empty, teardown) def test_failing_context_processing(): """Plug-in should not skip processing of Instance if Context fails""" diff --git a/tests/pre13/test_logic.py b/tests/pre13/test_logic.py index 39cd5bc8..3961ce04 100644 --- a/tests/pre13/test_logic.py +++ b/tests/pre13/test_logic.py @@ -211,6 +211,7 @@ def process(self, context): assert_equals(count["#"], 1) +@with_setup(lib.setup_empty, lib.teardown) def test_logic_process(): """logic.process works fine""" @@ -359,6 +360,7 @@ def process(self): assert_equals(count["#"], 111.1) +@with_setup(lib.setup_empty, lib.teardown) def test_test(): """The test halts an invalid publish""" diff --git a/tests/test_logic.py b/tests/test_logic.py index 7eb9156e..f83002c2 100644 --- a/tests/test_logic.py +++ b/tests/test_logic.py @@ -114,6 +114,7 @@ def process(self, instance): ["included_1", "included_2"]) +@with_setup(lib.setup_empty, lib.teardown) def test_subset_exact(): """Plugin.match = api.Exact works as expected""" diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 61272a89..eb4f1ff9 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -490,6 +490,7 @@ class MyPlugin(pyblish.plugin.Collector): pyblish.plugin.register_plugin(MyPlugin) +@with_setup(lib.setup_empty, lib.teardown) @mock.patch("pyblish.plugin.__explicit_process") def test_implicit_explicit_branching(func): """Explicit plug-ins are processed by the appropriate function""" @@ -504,6 +505,7 @@ class Explicit(pyblish.plugin.ContextPlugin): assert func.call_count == 1, func.call_count +@with_setup(lib.setup_empty, lib.teardown) @mock.patch("pyblish.plugin.__implicit_process") def test_implicit_branching(func): """Implicit plug-ins are processed by the appropriate function""" @@ -515,6 +517,7 @@ class Implicit(pyblish.plugin.Plugin): assert func.call_count == 1, func.call_count +@with_setup(lib.setup_empty, lib.teardown) def test_explicit_plugin(): """ContextPlugin works as advertised""" @@ -600,6 +603,7 @@ def process(self, context): action=MyAction.id) +@with_setup(lib.setup_empty, lib.teardown) def test_explicit_results(): """Explicit plug-ins contain results""" @@ -616,6 +620,7 @@ def process(self, context): assert result["records"][0].msg == "logged" +@with_setup(lib.setup_empty, lib.teardown) def test_cooperative_collection(): """Cooperative collection works diff --git a/tests/test_simple.py b/tests/test_simple.py index d1fce2ce..501d89d9 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -41,6 +41,7 @@ def process(self, context): assert_equals(count["#"], 2) +@with_setup(lib.setup_empty, lib.teardown) def test_simple_manual(): """Simple plug-ins work well""" @@ -57,6 +58,7 @@ def process(self): assert_equals(count["#"], 1) +@with_setup(lib.setup_empty, lib.teardown) def test_simple_instance(): """Simple plug-ins process instances as usual diff --git a/tests/test_util.py b/tests/test_util.py index 8fa07f32..64be3db2 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -8,6 +8,7 @@ ) +@with_setup(lib.setup_empty, lib.teardown) def test_convenience_plugins_argument(): """util._convenience() `plugins` argument works From 8e60cb71ba04781551823420ce77bf78efa90308 Mon Sep 17 00:00:00 2001 From: Jeremy Retailleau Date: Sun, 8 Mar 2020 18:58:54 -0700 Subject: [PATCH 05/12] Add unit tests for iterator with explicit targets --- tests/test_logic.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/test_logic.py b/tests/test_logic.py index f83002c2..4c50e539 100644 --- a/tests/test_logic.py +++ b/tests/test_logic.py @@ -67,6 +67,48 @@ def process(self, instance): assert count["#"] == 101, count +@with_setup(lib.setup, lib.teardown) +def test_iterator_with_explicit_targets(): + """Iterator skips non-targeted plug-ins""" + + count = {"#": 0} + + class MyCollectorA(api.ContextPlugin): + order = api.CollectorOrder + targets = ["studio"] + + def process(self, context): + count["#"] += 1 + + class MyCollectorB(api.ContextPlugin): + order = api.CollectorOrder + + def process(self, context): + count["#"] += 10 + + class MyCollectorC(api.ContextPlugin): + order = api.CollectorOrder + targets = ["studio"] + + def process(self, context): + count["#"] += 100 + + context = api.Context() + plugins = [MyCollectorA, MyCollectorB, MyCollectorC] + + assert count["#"] == 0, count + + for Plugin, instance in logic.Iterator( + plugins, context, targets=["studio"] + ): + assert Plugin.__name__ != "MyCollectorB" + + plugin.process(Plugin, context, instance) + + # Collector runs once, one Validator runs once + assert count["#"] == 101, count + + def test_register_gui(): """Registering at run-time takes precedence over those from environment""" From 57888949123220145611af4b90ecd77ffa34d3f7 Mon Sep 17 00:00:00 2001 From: Jeremy Retailleau Date: Sun, 8 Mar 2020 19:04:19 -0700 Subject: [PATCH 06/12] Add unit tests to ensure that explicit targets don't mess up globally registered targets --- tests/test_util.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/test_util.py b/tests/test_util.py index 64be3db2..3db90433 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -237,8 +237,8 @@ def process(self, context): @with_setup(lib.setup, lib.teardown) -def test_publishing_targets(): - """Publishing with targets works""" +def test_publishing_explicit_targets(): + """Publishing with explicit targets works""" count = {"#": 0} @@ -255,6 +255,28 @@ def process(self, context): assert count["#"] == 1, count +@with_setup(lib.setup, lib.teardown) +def test_publishing_explicit_targets_with_global(): + """Publishing with explicit and globally registered targets works""" + + count = {"#": 0} + + class plugin(api.ContextPlugin): + targets = ["custom"] + + def process(self, context): + count["#"] += 1 + + api.register_target("foo") + api.register_target("custom") + api.register_plugin(plugin) + + util.publish(targets=["custom"]) + + assert count["#"] == 1, count + assert api.registered_targets() == ["foo", "custom"] + + @with_setup(lib.setup, lib.teardown) def test_per_session_targets(): """Register targets per session works""" From 70c06b1d8cfd5995771e1c55c06737c565bef339 Mon Sep 17 00:00:00 2001 From: Jeremy Retailleau Date: Mon, 9 Mar 2020 13:09:01 -0700 Subject: [PATCH 07/12] Update logic to include registered targets only no explicit targets are passed --- pyblish/logic.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyblish/logic.py b/pyblish/logic.py index 792cc204..8f8cbd6f 100644 --- a/pyblish/logic.py +++ b/pyblish/logic.py @@ -356,10 +356,12 @@ def Iterator(plugins, context, state=None, targets=None): } # Include "default" target when no targets are requested. - targets = targets or ["default"] - targets += registered_targets() + _targets = targets or ["default"] - plugins = plugins_by_targets(plugins, targets) + if targets is None: + _targets += registered_targets() + + plugins = plugins_by_targets(plugins, _targets) for plugin in plugins: if not plugin.active: From f97bcd3893e60f3b3a51659590f729989cfc8ebe Mon Sep 17 00:00:00 2001 From: Jeremy Retailleau Date: Mon, 9 Mar 2020 13:15:48 -0700 Subject: [PATCH 08/12] Update unit tests to ensure that explicit targets override registered ones --- tests/test_util.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/test_util.py b/tests/test_util.py index 3db90433..31fd051d 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -261,15 +261,22 @@ def test_publishing_explicit_targets_with_global(): count = {"#": 0} - class plugin(api.ContextPlugin): + class Plugin1(api.ContextPlugin): targets = ["custom"] def process(self, context): count["#"] += 1 + class Plugin2(api.ContextPlugin): + targets = ["foo"] + + def process(self, context): + count["#"] += 10 + api.register_target("foo") api.register_target("custom") - api.register_plugin(plugin) + api.register_plugin(Plugin1) + api.register_plugin(Plugin2) util.publish(targets=["custom"]) From 52423ff0a4b42d9cb1e8473602e3b399b69f1191 Mon Sep 17 00:00:00 2001 From: Jeremy Retailleau Date: Fri, 20 Mar 2020 10:27:04 -0700 Subject: [PATCH 09/12] Adjust style for consistency --- pyblish/util.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pyblish/util.py b/pyblish/util.py index 1e0890b2..87aaa62a 100644 --- a/pyblish/util.py +++ b/pyblish/util.py @@ -120,9 +120,9 @@ def _convenience_iter(context=None, plugins=None, targets=None, order=None): # First pass, collection tasks_processed_count = 1 - for Plugin, instance in logic.Iterator( - collectors, context, targets=targets - ): + for Plugin, instance in logic.Iterator(collectors, + context, + targets=targets): result = plugin.process(Plugin, context, instance) # Inject additional member for results here. @@ -148,9 +148,10 @@ def _convenience_iter(context=None, plugins=None, targets=None, order=None): } # Second pass, the remainder - for Plugin, instance in logic.Iterator( - plugins, context, state, targets=targets - ): + for Plugin, instance in logic.Iterator(plugins, + context, + state, + targets=targets): try: result = plugin.process(Plugin, context, instance) result["progress"] = ( From 61a11eb5c8c7dfe01f8d3d90bcf56cc5f6c0dada Mon Sep 17 00:00:00 2001 From: Jeremy Retailleau Date: Fri, 20 Mar 2020 11:39:50 -0700 Subject: [PATCH 10/12] Remove all changes in unit tests that don't seem necessary --- tests/lib.py | 10 ++-------- tests/pre11/lib.py | 10 ++-------- tests/pre11/test_logic.py | 1 - tests/pre13/test_logic.py | 2 -- tests/test_logic.py | 2 -- tests/test_plugin.py | 5 ----- tests/test_simple.py | 2 -- tests/test_util.py | 4 ++-- 8 files changed, 6 insertions(+), 30 deletions(-) diff --git a/tests/lib.py b/tests/lib.py index e18e84b4..1982096c 100644 --- a/tests/lib.py +++ b/tests/lib.py @@ -13,8 +13,7 @@ HOST = 'python' FAMILY = 'test.family' -REGISTERED_PATHS = pyblish.plugin.registered_paths() -REGISTERED_TARGETS = pyblish.plugin.registered_targets() +REGISTERED = pyblish.plugin.registered_paths() PACKAGEPATH = pyblish.lib.main_package_path() ENVIRONMENT = os.environ.get("PYBLISHPLUGINPATH", "") PLUGINPATH = os.path.join(PACKAGEPATH, '..', 'tests', 'plugins') @@ -23,7 +22,6 @@ def setup(): """Disable default plugins and only use test plugins""" pyblish.plugin.deregister_all_paths() - pyblish.plugin.deregister_all_targets() def setup_empty(): @@ -41,13 +39,9 @@ def teardown(): """Restore previously REGISTERED paths""" pyblish.plugin.deregister_all_paths() - for path in REGISTERED_PATHS: + for path in REGISTERED: pyblish.plugin.register_plugin_path(path) - pyblish.plugin.deregister_all_targets() - for target in REGISTERED_TARGETS: - pyblish.plugin.register_target(target) - os.environ["PYBLISHPLUGINPATH"] = ENVIRONMENT pyblish.api.deregister_all_plugins() pyblish.api.deregister_all_hosts() diff --git a/tests/pre11/lib.py b/tests/pre11/lib.py index 6fddf79c..a1bbb876 100644 --- a/tests/pre11/lib.py +++ b/tests/pre11/lib.py @@ -7,8 +7,7 @@ HOST = 'python' FAMILY = 'test.family' -REGISTERED_PATHS = pyblish.plugin.registered_paths() -REGISTERED_TARGETS = pyblish.plugin.registered_targets() +REGISTERED = pyblish.plugin.registered_paths() PACKAGEPATH = pyblish.lib.main_package_path() PLUGINPATH = os.path.join(PACKAGEPATH, '..', 'tests', 'pre11', 'plugins') ENVIRONMENT = os.environ.get("PYBLISHPLUGINPATH", "") @@ -17,7 +16,6 @@ def setup(): """Disable default plugins and only use test plugins""" pyblish.plugin.deregister_all_paths() - pyblish.plugin.deregister_all_targets() pyblish.plugin.register_plugin_path(PLUGINPATH) @@ -80,13 +78,9 @@ def teardown(): """Restore previously REGISTERED paths""" pyblish.plugin.deregister_all_paths() - for path in REGISTERED_PATHS: + for path in REGISTERED: pyblish.plugin.register_plugin_path(path) - pyblish.plugin.deregister_all_targets() - for target in REGISTERED_TARGETS: - pyblish.plugin.register_target(target) - os.environ["PYBLISHPLUGINPATH"] = ENVIRONMENT pyblish.api.deregister_all_plugins() diff --git a/tests/pre11/test_logic.py b/tests/pre11/test_logic.py index 541d62f1..d031303d 100644 --- a/tests/pre11/test_logic.py +++ b/tests/pre11/test_logic.py @@ -227,7 +227,6 @@ def process_instance(self, instance): assert_equals(_server["assets"][0].metadata, "123") -@with_setup(setup_empty, teardown) def test_failing_context_processing(): """Plug-in should not skip processing of Instance if Context fails""" diff --git a/tests/pre13/test_logic.py b/tests/pre13/test_logic.py index 3961ce04..39cd5bc8 100644 --- a/tests/pre13/test_logic.py +++ b/tests/pre13/test_logic.py @@ -211,7 +211,6 @@ def process(self, context): assert_equals(count["#"], 1) -@with_setup(lib.setup_empty, lib.teardown) def test_logic_process(): """logic.process works fine""" @@ -360,7 +359,6 @@ def process(self): assert_equals(count["#"], 111.1) -@with_setup(lib.setup_empty, lib.teardown) def test_test(): """The test halts an invalid publish""" diff --git a/tests/test_logic.py b/tests/test_logic.py index 4c50e539..0ff44b58 100644 --- a/tests/test_logic.py +++ b/tests/test_logic.py @@ -67,7 +67,6 @@ def process(self, instance): assert count["#"] == 101, count -@with_setup(lib.setup, lib.teardown) def test_iterator_with_explicit_targets(): """Iterator skips non-targeted plug-ins""" @@ -156,7 +155,6 @@ def process(self, instance): ["included_1", "included_2"]) -@with_setup(lib.setup_empty, lib.teardown) def test_subset_exact(): """Plugin.match = api.Exact works as expected""" diff --git a/tests/test_plugin.py b/tests/test_plugin.py index eb4f1ff9..61272a89 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -490,7 +490,6 @@ class MyPlugin(pyblish.plugin.Collector): pyblish.plugin.register_plugin(MyPlugin) -@with_setup(lib.setup_empty, lib.teardown) @mock.patch("pyblish.plugin.__explicit_process") def test_implicit_explicit_branching(func): """Explicit plug-ins are processed by the appropriate function""" @@ -505,7 +504,6 @@ class Explicit(pyblish.plugin.ContextPlugin): assert func.call_count == 1, func.call_count -@with_setup(lib.setup_empty, lib.teardown) @mock.patch("pyblish.plugin.__implicit_process") def test_implicit_branching(func): """Implicit plug-ins are processed by the appropriate function""" @@ -517,7 +515,6 @@ class Implicit(pyblish.plugin.Plugin): assert func.call_count == 1, func.call_count -@with_setup(lib.setup_empty, lib.teardown) def test_explicit_plugin(): """ContextPlugin works as advertised""" @@ -603,7 +600,6 @@ def process(self, context): action=MyAction.id) -@with_setup(lib.setup_empty, lib.teardown) def test_explicit_results(): """Explicit plug-ins contain results""" @@ -620,7 +616,6 @@ def process(self, context): assert result["records"][0].msg == "logged" -@with_setup(lib.setup_empty, lib.teardown) def test_cooperative_collection(): """Cooperative collection works diff --git a/tests/test_simple.py b/tests/test_simple.py index 501d89d9..d1fce2ce 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -41,7 +41,6 @@ def process(self, context): assert_equals(count["#"], 2) -@with_setup(lib.setup_empty, lib.teardown) def test_simple_manual(): """Simple plug-ins work well""" @@ -58,7 +57,6 @@ def process(self): assert_equals(count["#"], 1) -@with_setup(lib.setup_empty, lib.teardown) def test_simple_instance(): """Simple plug-ins process instances as usual diff --git a/tests/test_util.py b/tests/test_util.py index 31fd051d..31fe07b7 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -8,7 +8,6 @@ ) -@with_setup(lib.setup_empty, lib.teardown) def test_convenience_plugins_argument(): """util._convenience() `plugins` argument works @@ -255,7 +254,6 @@ def process(self, context): assert count["#"] == 1, count -@with_setup(lib.setup, lib.teardown) def test_publishing_explicit_targets_with_global(): """Publishing with explicit and globally registered targets works""" @@ -283,6 +281,8 @@ def process(self, context): assert count["#"] == 1, count assert api.registered_targets() == ["foo", "custom"] + api.deregister_all_targets() + @with_setup(lib.setup, lib.teardown) def test_per_session_targets(): From 767632ebb94b8e4389e3a2711abcd957f7e602e3 Mon Sep 17 00:00:00 2001 From: Jeremy Retailleau Date: Fri, 20 Mar 2020 12:32:37 -0700 Subject: [PATCH 11/12] Refactor logic for clarity --- pyblish/logic.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pyblish/logic.py b/pyblish/logic.py index 8f8cbd6f..ed948de7 100644 --- a/pyblish/logic.py +++ b/pyblish/logic.py @@ -355,13 +355,12 @@ def Iterator(plugins, context, state=None, targets=None): "ordersWithError": set() } - # Include "default" target when no targets are requested. - _targets = targets or ["default"] + # Include "default" target and registered targets when no targets are + # explicitly requested. + if not targets: + targets = ["default"] + registered_targets() - if targets is None: - _targets += registered_targets() - - plugins = plugins_by_targets(plugins, _targets) + plugins = plugins_by_targets(plugins, targets) for plugin in plugins: if not plugin.active: From 08e6373024a24e8f4c6fd0ec4dc3c24849364fb7 Mon Sep 17 00:00:00 2001 From: Marcus Ottosson Date: Sat, 21 Mar 2020 09:03:27 +0100 Subject: [PATCH 12/12] Update version.py --- pyblish/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyblish/version.py b/pyblish/version.py index 5dfb869a..fb828024 100644 --- a/pyblish/version.py +++ b/pyblish/version.py @@ -1,7 +1,7 @@ VERSION_MAJOR = 1 VERSION_MINOR = 8 -VERSION_PATCH = 4 +VERSION_PATCH = 5 version_info = (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH) version = '%i.%i.%i' % version_info