Skip to content

Commit

Permalink
Remove Python 2 support and dependency on py, fixes #81
Browse files Browse the repository at this point in the history
  • Loading branch information
erikkemperman committed Oct 16, 2021
1 parent 9db176c commit eda4ef7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
29 changes: 18 additions & 11 deletions pytest_flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit eda4ef7

Please sign in to comment.