From eca301c05b5a5ae9b6896128a44fe2b6c7883c4d Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 3 May 2021 14:34:07 +0200 Subject: [PATCH] Fix patching of open() for Python 3.4 It doesn't handle builtins automatically, so follow the recommendations from that time. --- tests/test_token_plugins.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_token_plugins.py b/tests/test_token_plugins.py index 9254256..17218bb 100644 --- a/tests/test_token_plugins.py +++ b/tests/test_token_plugins.py @@ -16,7 +16,7 @@ class ReadOnlyTokenFileTestCase(unittest.TestCase): config = "" pyopen = mock_open(read_data=config) - with patch("websockify.token_plugins.open", pyopen): + with patch("websockify.token_plugins.open", pyopen, create=True): result = plugin.lookup('testhost') pyopen.assert_called_once_with('configfile') @@ -29,7 +29,7 @@ class ReadOnlyTokenFileTestCase(unittest.TestCase): config = "testhost: remote_host:remote_port" pyopen = mock_open(read_data=config) - with patch("websockify.token_plugins.open", pyopen): + with patch("websockify.token_plugins.open", pyopen, create=True): result = plugin.lookup('testhost') pyopen.assert_called_once_with('configfile') @@ -44,7 +44,7 @@ class ReadOnlyTokenFileTestCase(unittest.TestCase): config = "testhost:\tremote_host:remote_port" pyopen = mock_open(read_data=config) - with patch("websockify.token_plugins.open", pyopen): + with patch("websockify.token_plugins.open", pyopen, create=True): result = plugin.lookup('testhost') pyopen.assert_called_once_with('configfile')