Skip to content

Commit b436a44

Browse files
committed
Drop testfixtures dependency
The Python versions supported by this package all have `contextlib.redirect_stdout`
1 parent c8072e0 commit b436a44

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

flake8_isort.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
# -*- coding: utf-8 -*-
22

3-
import isort
4-
3+
from contextlib import redirect_stdout
4+
from difflib import Differ
5+
from difflib import unified_diff
6+
from io import StringIO
7+
from pathlib import Path
58

6-
if hasattr(isort, 'api'): # isort 5
7-
from contextlib import redirect_stdout
8-
from difflib import unified_diff
9-
from io import StringIO
10-
from pathlib import Path
9+
import isort
10+
import warnings
1111

12-
import warnings
13-
else:
14-
from difflib import Differ
15-
from testfixtures import OutputCapture
1612

1713
__version__ = '4.1.2.dev0'
1814

@@ -46,7 +42,6 @@ def __init__(self, tree, filename, lines):
4642

4743
@classmethod
4844
def add_options(cls, parser):
49-
5045
parser.add_option(
5146
'--isort-show-traceback',
5247
action='store_true',
@@ -68,7 +63,8 @@ def run(self):
6863
file_path = self.filename
6964
else:
7065
file_path = None
71-
with OutputCapture() as buffer:
66+
buffer = StringIO()
67+
with redirect_stdout(buffer):
7268
sort_result = isort.SortImports(
7369
file_path=file_path,
7470
file_contents=''.join(self.lines),
@@ -129,7 +125,7 @@ def _format_isort_output(self, isort_buffer):
129125
valid_lines = ['']
130126
valid_lines += [
131127
line
132-
for line in isort_buffer.output.getvalue().splitlines()
128+
for line in isort_buffer.getvalue().splitlines()
133129
if line.strip().split(' ', 1)[0] not in filtering_out
134130
]
135131

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def get_version(file="flake8_isort.py"):
5757
install_requires=[
5858
'flake8 >= 3.2.1, <5',
5959
'isort >= 4.3.5, <6',
60-
'testfixtures >= 6.8.0, <7',
6160
],
6261
extras_require={
6362
'test': ['pytest-cov'],

0 commit comments

Comments
 (0)