diff --git a/pyblish/__init__.py b/pyblish/__init__.py index dba65fb5..51546b9f 100644 --- a/pyblish/__init__.py +++ b/pyblish/__init__.py @@ -14,4 +14,4 @@ _registered_plugins = dict() _registered_services = dict() _registered_test = None -_registered_hosts = set() +_registered_hosts = list() diff --git a/pyblish/plugin.py b/pyblish/plugin.py index daa3c8fc..6db3e2b9 100644 --- a/pyblish/plugin.py +++ b/pyblish/plugin.py @@ -875,7 +875,8 @@ def register_host(host): """ - pyblish._registered_hosts.add(host) + if not host in pyblish._registered_hosts: + pyblish._registered_hosts.append(host) def deregister_host(host, quiet=False): @@ -897,7 +898,7 @@ def deregister_host(host, quiet=False): def deregister_all_hosts(): - pyblish._registered_hosts.clear() + pyblish._registered_hosts[:] = [] def registered_hosts(): diff --git a/tests/lib.py b/tests/lib.py index 8987049a..acf14321 100644 --- a/tests/lib.py +++ b/tests/lib.py @@ -28,6 +28,7 @@ def setup_empty(): """Disable all plug-ins""" setup() pyblish.plugin.deregister_all_paths() + pyblish.plugin.deregister_all_hosts() def teardown(): @@ -42,4 +43,6 @@ def teardown(): os.environ["PYBLISHPLUGINPATH"] = ENVIRONMENT pyblish.api.deregister_all_plugins() + pyblish.api.deregister_all_hosts() pyblish.api.deregister_test() + pyblish.api.__init__() diff --git a/tests/test_plugin.py b/tests/test_plugin.py index dee9b150..23430bda 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -221,3 +221,19 @@ def process(self, context): records = results["records"] hello_world = records[0] assert_equals(hello_world.msg, "Hello world") + + +@with_setup(lib.setup_empty, lib.teardown) +def test_current_host(): + """pyblish.api.current_host works""" + pyblish.plugin.register_host("myhost") + assert_equals(pyblish.plugin.current_host(), "myhost") + + +@with_setup(lib.setup_empty, lib.teardown) +def test_register_host(): + """Registering and deregistering hosts works fine""" + pyblish.plugin.register_host("myhost") + assert "myhost" in pyblish.plugin.registered_hosts() + pyblish.plugin.deregister_host("myhost") + assert "myhost" not in pyblish.plugin.registered_hosts()