if mpd_host_env[0]:
# A password is actually set
self.pwd = mpd_host_env[0]
- self.host = mpd_host_env[1]
+ if mpd_host_env[1]:
+ self.host = mpd_host_env[1]
else:
# No password set but leading @ is an abstract socket
self.host = '@'+mpd_host_env[1]
self.assertEqual(client.pwd, 'pa55w04d')
self.assertEqual(client.host, 'example.org')
+ # Test password extraction (no host)
+ os.environ['MPD_HOST'] = 'pa55w04d@'
+ with mock.patch('os.path.exists', return_value=False):
+ client = musicpd.MPDClient()
+ self.assertEqual(client.pwd, 'pa55w04d')
+ self.assertEqual(client.host, 'localhost')
+
# Test unix socket extraction
os.environ['MPD_HOST'] = 'pa55w04d@/unix/sock'
client = musicpd.MPDClient()