+ # Test host alone
+ os.environ['MPD_HOST'] = 'example.org'
+ client = musicpd.MPDClient()
+ self.assertFalse(client.pwd)
+ 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 badly formatted MPD_HOST
+ os.environ['MPD_HOST'] = '@'
+ with mock.patch('os.path.exists', return_value=False):
+ client = musicpd.MPDClient()
+ self.assertEqual(client.pwd, None)
+ self.assertEqual(client.host, 'localhost')
+