Fix patching of open() for Python 3.4

It doesn't handle builtins automatically, so follow the recommendations
from that time.
This commit is contained in:
Pierre Ossman 2021-05-03 14:34:07 +02:00
parent b9b269c73f
commit eca301c05b
1 changed files with 3 additions and 3 deletions

View File

@ -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')