diff --git a/pytest_flake8.py b/pytest_flake8.py index 1e45d8f..5774714 100644 --- a/pytest_flake8.py +++ b/pytest_flake8.py @@ -2,12 +2,12 @@ import os import re +from contextlib import redirect_stdout, redirect_stderr +from io import BytesIO, TextIOWrapper from flake8.main import application from flake8.options import config -import py - import pytest __version__ = '0.6' @@ -116,15 +116,22 @@ def setup(self): pytest.skip("file(s) previously passed FLAKE8 checks") def runtest(self): - call = py.io.StdCapture.call - found_errors, out, err = call( - check_file, - self.fspath, - self.flake8ignore, - self.maxlength, - self.maxcomplexity, - self.showshource, - self.statistics) + with BytesIO() as bo, TextIOWrapper(bo, encoding='utf-8') as to, \ + BytesIO() as be, TextIOWrapper(be, encoding='utf-8') as te, \ + redirect_stdout(to), redirect_stderr(te): + found_errors = check_file( + self.fspath, + self.flake8ignore, + self.maxlength, + self.maxcomplexity, + self.showshource, + self.statistics + ) + to.flush() + te.flush() + out = bo.getvalue().decode('utf-8') + err = be.getvalue().decode('utf-8') + if found_errors: raise Flake8Error(out, err) # update mtime only if test passed diff --git a/setup.py b/setup.py index 50e91c9..1dfdf3c 100644 --- a/setup.py +++ b/setup.py @@ -14,13 +14,13 @@ "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development", diff --git a/tox.ini b/tox.ini index 12da49e..343cfdd 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist=py27,py36-pytesttrunk,py36-xdist,py34,py35,py36,py37,py38,pypy,pypy3 +envlist=py36-pytesttrunk,py36-xdist,py35,py36,py37,py38,py39,py310,pypy,pypy3 [testenv] deps=pytest