|
4 | 4 | """functional/non regression tests for pylint"""
|
5 | 5 | import contextlib
|
6 | 6 | import functools
|
7 |
| -import tempfile |
8 | 7 | import tokenize
|
9 | 8 | from glob import glob
|
10 | 9 | from io import StringIO
|
11 |
| -from os import close, remove, write |
12 | 10 | from os.path import basename, join, splitext
|
13 | 11 |
|
14 |
| -import astroid |
15 |
| - |
16 | 12 | from pylint import checkers
|
17 | 13 | from pylint.lint import PyLinter
|
18 | 14 | from pylint.testutils.constants import SYS_VERS_STR
|
@@ -164,33 +160,3 @@ def walk(self, node):
|
164 | 160 |
|
165 | 161 | def _tokenize_str(code):
|
166 | 162 | 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