diff --git a/pyls/plugins/flake8_lint.py b/pyls/plugins/flake8_lint.py index 69f3f40a..2b55e17d 100644 --- a/pyls/plugins/flake8_lint.py +++ b/pyls/plugins/flake8_lint.py @@ -58,11 +58,10 @@ def run_flake8(args): cmd = ['python', '-m', 'flake8'] cmd.extend(args) p = Popen(cmd, stdout=PIPE, stderr=PIPE) - stderr = p.stderr.read().decode() + (stdout, stderr) = p.communicate() if stderr: - log.error("Error while running flake8 '%s'", stderr) - stdout = p.stdout - return stdout.read().decode() + log.error("Error while running flake8 '%s'", stderr.decode()) + return stdout.decode() def build_args(options, doc_path): diff --git a/test/plugins/test_flake8_lint.py b/test/plugins/test_flake8_lint.py index 326f93b9..795aa93e 100644 --- a/test/plugins/test_flake8_lint.py +++ b/test/plugins/test_flake8_lint.py @@ -57,6 +57,8 @@ def test_flake8_lint(config): def test_flake8_config_param(config): with patch('pyls.plugins.flake8_lint.Popen') as popen_mock: + mock_instance = popen_mock.return_value + mock_instance.communicate.return_value = [bytes(), bytes()] flake8_conf = '/tmp/some.cfg' config.update({'plugins': {'flake8': {'config': flake8_conf}}}) _name, doc = temp_document(DOC)