Skip to content

Commit

Permalink
Continue to remove six
Browse files Browse the repository at this point in the history
  • Loading branch information
dbieber committed Sep 20, 2024
1 parent 7cb47e3 commit 69fe541
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
5 changes: 2 additions & 3 deletions fire/parser_fuzz_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from hypothesis import settings
from hypothesis import strategies as st
import Levenshtein
import six


class ParserFuzzTest(testutils.BaseTestCase):
Expand Down Expand Up @@ -64,8 +63,8 @@ def testDefaultParseValueFuzz(self, value):
raise

try:
uvalue = six.text_type(value)
uresult = six.text_type(result)
uvalue = str(value)
uresult = str(result)
except UnicodeDecodeError:
# This is not what we're testing.
return
Expand Down
5 changes: 1 addition & 4 deletions fire/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
import enum
import functools

import six

if six.PY3:
from fire import test_components_py3 as py3 # pylint: disable=unused-import,no-name-in-module,g-import-not-at-top
from fire import test_components_py3 as py3 # pylint: disable=unused-import,no-name-in-module,g-import-not-at-top


def identity(arg1, arg2, arg3=10, arg4=20, *arg5, **arg6): # pylint: disable=keyword-arg-before-vararg
Expand Down
11 changes: 4 additions & 7 deletions fire/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""Utilities for Python Fire's tests."""

import contextlib
import io
import os
import re
import sys
Expand All @@ -24,7 +25,6 @@
from fire import trace

import mock
import six


class BaseTestCase(unittest.TestCase):
Expand All @@ -45,8 +45,8 @@ def assertOutputMatches(self, stdout='.*', stderr='.*', capture=True):
Yields:
Yields to the wrapped context.
"""
stdout_fp = six.StringIO()
stderr_fp = six.StringIO()
stdout_fp = io.StringIO()
stderr_fp = io.StringIO()
try:
with mock.patch.object(sys, 'stdout', stdout_fp):
with mock.patch.object(sys, 'stderr', stderr_fp):
Expand All @@ -69,10 +69,7 @@ def assertOutputMatches(self, stdout='.*', stderr='.*', capture=True):
(name, value, regexp))

def assertRaisesRegex(self, *args, **kwargs): # pylint: disable=arguments-differ
if sys.version_info.major == 2:
return super(BaseTestCase, self).assertRaisesRegexp(*args, **kwargs) # pylint: disable=deprecated-method,no-member
else:
return super(BaseTestCase, self).assertRaisesRegex(*args, **kwargs) # pylint: disable=no-member
return super(BaseTestCase, self).assertRaisesRegex(*args, **kwargs) # pylint: disable=no-member

@contextlib.contextmanager
def assertRaisesFireExit(self, code, regexp='.*'):
Expand Down
8 changes: 3 additions & 5 deletions fire/testutils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

from fire import testutils

import six


class TestTestUtils(testutils.BaseTestCase):
"""Let's get meta."""
Expand All @@ -30,15 +28,15 @@ def testNoCheckOnException(self):
raise ValueError()

def testCheckStdoutOrStderrNone(self):
with six.assertRaisesRegex(self, AssertionError, 'stdout:'):
with self.assertRaisesRegex(AssertionError, 'stdout:'):
with self.assertOutputMatches(stdout=None):
print('blah')

with six.assertRaisesRegex(self, AssertionError, 'stderr:'):
with self.assertRaisesRegex(AssertionError, 'stderr:'):
with self.assertOutputMatches(stderr=None):
print('blah', file=sys.stderr)

with six.assertRaisesRegex(self, AssertionError, 'stderr:'):
with self.assertRaisesRegex(AssertionError, 'stderr:'):
with self.assertOutputMatches(stdout='apple', stderr=None):
print('apple')
print('blah', file=sys.stderr)
Expand Down

0 comments on commit 69fe541

Please sign in to comment.