Skip to content

Commit

Permalink
update comment on localhost check and add test for case localhost4.lo…
Browse files Browse the repository at this point in the history
…calhost42
  • Loading branch information
wxtim committed Mar 20, 2023
1 parent 6a21157 commit 83484ef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cylc/flow/hostuserutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def is_remote_host(self, name):
"""
if name not in self._remote_hosts:
if not name or name.split(".")[0].startswith("localhost"):
# e.g. localhost.localdomain
# e.g. localhost42.localdomain42
self._remote_hosts[name] = False
else:
try:
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_hostuserutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ def test_is_remote_user_on_current_user():
assert not is_remote_user(os.getenv('USER'))


def test_is_remote_host_on_localhost():
def test_is_remote_host_on_localhost(monkeypatch):
"""is_remote_host with localhost."""
assert not is_remote_host(None)
assert not is_remote_host('localhost')
assert not is_remote_host('localhost4.localhost42')
assert not is_remote_host(os.getenv('HOSTNAME'))
assert not is_remote_host(get_host())

Expand Down

0 comments on commit 83484ef

Please sign in to comment.