Skip to content

Commit eca301c

Browse files
committed
Fix patching of open() for Python 3.4
It doesn't handle builtins automatically, so follow the recommendations from that time.
1 parent b9b269c commit eca301c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/test_token_plugins.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_empty(self):
1616
config = ""
1717
pyopen = mock_open(read_data=config)
1818

19-
with patch("websockify.token_plugins.open", pyopen):
19+
with patch("websockify.token_plugins.open", pyopen, create=True):
2020
result = plugin.lookup('testhost')
2121

2222
pyopen.assert_called_once_with('configfile')
@@ -29,7 +29,7 @@ def test_simple(self):
2929
config = "testhost: remote_host:remote_port"
3030
pyopen = mock_open(read_data=config)
3131

32-
with patch("websockify.token_plugins.open", pyopen):
32+
with patch("websockify.token_plugins.open", pyopen, create=True):
3333
result = plugin.lookup('testhost')
3434

3535
pyopen.assert_called_once_with('configfile')
@@ -44,7 +44,7 @@ def test_tabs(self):
4444
config = "testhost:\tremote_host:remote_port"
4545
pyopen = mock_open(read_data=config)
4646

47-
with patch("websockify.token_plugins.open", pyopen):
47+
with patch("websockify.token_plugins.open", pyopen, create=True):
4848
result = plugin.lookup('testhost')
4949

5050
pyopen.assert_called_once_with('configfile')

0 commit comments

Comments
 (0)