collection 교체

This commit is contained in:
정훈 변
2024-02-23 16:37:40 +09:00
parent b494779b5b
commit 3fd554eee9
38862 changed files with 220204 additions and 6600073 deletions

View File

@@ -18,14 +18,17 @@
# Make coding more python3-ish
from __future__ import absolute_import, division, print_function
__metaclass__ = type
"""
Compat module for Python3.x's unittest.mock module
"""
import _io
import sys
import _io # pyright: ignore[reportMissingImports]
# Python 2.7
# Note: Could use the pypi mock library on python3.x as well as python2.x. It
@@ -35,12 +38,12 @@ try:
# Allow wildcard import because we really do want to import all of mock's
# symbols into this compat shim
# pylint: disable=wildcard-import,unused-wildcard-import
from unittest.mock import *
from unittest.mock import * # noqa F403
except ImportError:
# Python 2
# pylint: disable=wildcard-import,unused-wildcard-import
try:
from mock import *
from mock import * # pyright: ignore[reportMissingModuleSource] # noqa F403
except ImportError:
print("You need the mock library installed on python2.x to run tests")
@@ -54,7 +57,7 @@ if sys.version_info >= (3,) and sys.version_info < (3, 4, 4):
# Retrieve lines from read_data via a generator so that separate calls to
# readline, read, and readlines are properly interleaved
sep = b"\n" if isinstance(read_data, bytes) else "\n"
data_as_list = [l + sep for l in read_data.split(sep)]
data_as_list = [line + sep for line in read_data.split(sep)]
if data_as_list[-1] == sep:
# If the last line ended in a newline, the list comprehension will have an
@@ -101,15 +104,12 @@ if sys.version_info >= (3,) and sys.version_info < (3, 4, 4):
global file_spec
if file_spec is None:
file_spec = list(
set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO)))
)
file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO))))
if mock is None:
mock = MagicMock(name="open", spec=open)
mock = MagicMock(name="open", spec=open) # noqa F405
handle = MagicMock(spec=file_spec)
handle = MagicMock(spec=file_spec) # noqa F405
handle.__enter__.return_value = handle
_data = _iterate_read_data(read_data)