Skip to content

Commit

Permalink
Fixes #215
Browse files Browse the repository at this point in the history
  • Loading branch information
mottosso committed Aug 4, 2015
1 parent b771160 commit fd4f110
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyblish/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
_registered_plugins = dict()
_registered_services = dict()
_registered_test = None
_registered_hosts = set()
_registered_hosts = list()
5 changes: 3 additions & 2 deletions pyblish/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -897,7 +898,7 @@ def deregister_host(host, quiet=False):


def deregister_all_hosts():
pyblish._registered_hosts.clear()
pyblish._registered_hosts[:] = []


def registered_hosts():
Expand Down
3 changes: 3 additions & 0 deletions tests/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def setup_empty():
"""Disable all plug-ins"""
setup()
pyblish.plugin.deregister_all_paths()
pyblish.plugin.deregister_all_hosts()


def teardown():
Expand All @@ -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__()
16 changes: 16 additions & 0 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit fd4f110

Please sign in to comment.