diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2020-11-29 10:49:11 +0100 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2020-11-29 11:59:49 +0100 |
commit | fa8f15d15c84815fee79e2504735f0b5d25c92ab (patch) | |
tree | 933d79be8872aee2834f2890f10aa5d6b3c6f4da | |
parent | 1d181c9d59fa769d3c85518a31a057240b793d42 (diff) | |
download | pylint-git-fa8f15d15c84815fee79e2504735f0b5d25c92ab.tar.gz |
Remove context manager replaced by pytest tmp_file/dir
-rw-r--r-- | pylint/testutils/utils.py | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/pylint/testutils/utils.py b/pylint/testutils/utils.py index 371f157b6..653db2b7a 100644 --- a/pylint/testutils/utils.py +++ b/pylint/testutils/utils.py @@ -4,15 +4,11 @@ """functional/non regression tests for pylint""" import contextlib import functools -import tempfile import tokenize from glob import glob from io import StringIO -from os import close, remove, write from os.path import basename, join, splitext -import astroid - from pylint import checkers from pylint.lint import PyLinter from pylint.testutils.constants import SYS_VERS_STR @@ -164,33 +160,3 @@ checkers.initialize(linter) def _tokenize_str(code): return list(tokenize.generate_tokens(StringIO(code).readline)) - - -@contextlib.contextmanager -def _create_tempfile(content=None): - """Create a new temporary file. - - If *content* parameter is given, then it will be written - in the temporary file, before passing it back. - This is a context manager and should be used with a *with* statement. - """ - # Can't use tempfile.NamedTemporaryFile here - # because on Windows the file must be closed before writing to it, - # see https://bugs.python.org/issue14243 - file_handle, tmp = tempfile.mkstemp() - if content: - write(file_handle, bytes(content, "ascii")) - try: - yield tmp - finally: - close(file_handle) - remove(tmp) - - -@contextlib.contextmanager -def _create_file_backed_module(code): - """Create an astroid module for the given code, backed by a real file.""" - with _create_tempfile() as temp: - module = astroid.parse(code) - module.file = temp - yield module |