#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
+# coding: utf-8
+# SPDX-FileCopyrightText: 2012-2021 kaliko <kaliko@azylum.org>
+# SPDX-License-Identifier: LGPL-3.0-or-later
# pylint: disable=missing-docstring
"""
Test suite highly borrowed^Wsteal from python-mpd2 [0] project.
with self.assertRaises(musicpd.CommandError):
cli.find('(album == "foo\nbar")')
+class testContextManager(unittest.TestCase):
+
+ def test_enter_exit(self):
+ os.environ['MPD_HOST'] = '@abstract'
+ with mock.patch('musicpd.socket') as socket_mock:
+ sock = mock.MagicMock(name='socket')
+ socket_mock.socket.return_value = sock
+ cli = musicpd.MPDClient()
+ with cli as c:
+ sock.connect.assert_called_with('\0abstract')
+ sock.close.assert_not_called()
+ sock.close.assert_called()
if __name__ == '__main__':
unittest.main()