Skip to content

Commit fa8f15d

Browse files
Remove context manager replaced by pytest tmp_file/dir
1 parent 1d181c9 commit fa8f15d

File tree

1 file changed

+0
-34
lines changed

1 file changed

+0
-34
lines changed

pylint/testutils/utils.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@
44
"""functional/non regression tests for pylint"""
55
import contextlib
66
import functools
7-
import tempfile
87
import tokenize
98
from glob import glob
109
from io import StringIO
11-
from os import close, remove, write
1210
from os.path import basename, join, splitext
1311

14-
import astroid
15-
1612
from pylint import checkers
1713
from pylint.lint import PyLinter
1814
from pylint.testutils.constants import SYS_VERS_STR
@@ -164,33 +160,3 @@ def walk(self, node):
164160

165161
def _tokenize_str(code):
166162
return list(tokenize.generate_tokens(StringIO(code).readline))
167-
168-
169-
@contextlib.contextmanager
170-
def _create_tempfile(content=None):
171-
"""Create a new temporary file.
172-
173-
If *content* parameter is given, then it will be written
174-
in the temporary file, before passing it back.
175-
This is a context manager and should be used with a *with* statement.
176-
"""
177-
# Can't use tempfile.NamedTemporaryFile here
178-
# because on Windows the file must be closed before writing to it,
179-
# see https://bugs.python.org/issue14243
180-
file_handle, tmp = tempfile.mkstemp()
181-
if content:
182-
write(file_handle, bytes(content, "ascii"))
183-
try:
184-
yield tmp
185-
finally:
186-
close(file_handle)
187-
remove(tmp)
188-
189-
190-
@contextlib.contextmanager
191-
def _create_file_backed_module(code):
192-
"""Create an astroid module for the given code, backed by a real file."""
193-
with _create_tempfile() as temp:
194-
module = astroid.parse(code)
195-
module.file = temp
196-
yield module

0 commit comments

Comments
 (0)