Kaydet (Commit) a74561a5 authored tarafından Michael Foord's avatar Michael Foord

unittest.mock: set file_spec on first use

üst 50a8c0ef
......@@ -2138,11 +2138,15 @@ FunctionAttributes = set([
'func_name',
])
import _io
file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO))))
file_spec = None
def mock_open(mock=None, read_data=None):
global file_spec
if file_spec is None:
import _io
file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO))))
if mock is None:
mock = MagicMock(spec=file_spec)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment