summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Finucane <stephenfin@redhat.com>2021-12-15 10:44:00 +0000
committerStephen Finucane <stephenfin@redhat.com>2021-12-15 10:44:00 +0000
commitcbaa3177ea546088c1383f1f01176754c19b52c2 (patch)
tree3edeeb4743263202ad18b15c5105e206647bfffb
parent01682c1dcfd5fa92f08c00437fadb4650b8d4bf9 (diff)
downloadsubunit-git-cbaa3177ea546088c1383f1f01176754c19b52c2.tar.gz
Stop using io imports from testtools
We no longer need to worry about Python 2, so we can just import directly from 'io'. Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
-rw-r--r--python/subunit/__init__.py11
-rw-r--r--python/subunit/details.py8
-rw-r--r--python/subunit/tests/test_chunked.py7
-rw-r--r--python/subunit/tests/test_details.py4
-rw-r--r--python/subunit/tests/test_subunit_filter.py9
-rw-r--r--python/subunit/tests/test_subunit_stats.py8
-rw-r--r--python/subunit/tests/test_test_protocol.py6
-rw-r--r--python/subunit/tests/test_test_results.py7
8 files changed, 18 insertions, 42 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py
index 614c647..9d8bc7c 100644
--- a/python/subunit/__init__.py
+++ b/python/subunit/__init__.py
@@ -115,25 +115,20 @@ Utility modules
* subunit.test_results contains TestResult helper classes.
"""
+from io import BytesIO
+from io import StringIO
+from io import UnsupportedOperation as _UnsupportedOperation
import os
import re
import subprocess
import sys
import unittest
-try:
- from io import UnsupportedOperation as _UnsupportedOperation
-except ImportError:
- _UnsupportedOperation = AttributeError
from extras import safe_hasattr
from testtools import content, content_type, ExtendedToOriginalDecorator
from testtools.content import TracebackContent
from testtools.compat import _b, _u
try:
- from testtools.compat import BytesIO, StringIO
-except ImportError:
- from io import BytesIO, StringIO
-try:
from testtools.testresult.real import _StringException
RemoteException = _StringException
except ImportError:
diff --git a/python/subunit/details.py b/python/subunit/details.py
index 5105580..f231cf6 100644
--- a/python/subunit/details.py
+++ b/python/subunit/details.py
@@ -6,7 +6,7 @@
# license at the users choice. A copy of both licenses are available in the
# project source as Apache-2.0 and BSD. You may not use this file except in
# compliance with one of these two licences.
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -16,12 +16,10 @@
"""Handlers for outcome details."""
+from io import BytesIO, StringIO
+
from testtools import content, content_type
from testtools.compat import _b
-try:
- from testtools.compat import BytesIO, StringIO
-except ImportError:
- from io import BytesIO, StringIO
from subunit import chunked
diff --git a/python/subunit/tests/test_chunked.py b/python/subunit/tests/test_chunked.py
index 46cf150..21f4814 100644
--- a/python/subunit/tests/test_chunked.py
+++ b/python/subunit/tests/test_chunked.py
@@ -7,7 +7,7 @@
# license at the users choice. A copy of both licenses are available in the
# project source as Apache-2.0 and BSD. You may not use this file except in
# compliance with one of these two licences.
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -15,13 +15,10 @@
# limitations under that license.
#
+from io import BytesIO
import unittest
from testtools.compat import _b
-try:
- from testtools.compat import BytesIO
-except ImportError:
- from io import BytesIO
import subunit.chunked
diff --git a/python/subunit/tests/test_details.py b/python/subunit/tests/test_details.py
index f3c70d2..b2c0440 100644
--- a/python/subunit/tests/test_details.py
+++ b/python/subunit/tests/test_details.py
@@ -17,10 +17,6 @@
import unittest
from testtools.compat import _b
-try:
- from testtools.compat import StringIO
-except ImportError:
- from io import StringIO
import subunit.tests
from subunit import content, content_type, details
diff --git a/python/subunit/tests/test_subunit_filter.py b/python/subunit/tests/test_subunit_filter.py
index 364fad9..7ca0081 100644
--- a/python/subunit/tests/test_subunit_filter.py
+++ b/python/subunit/tests/test_subunit_filter.py
@@ -17,21 +17,18 @@
"""Tests for subunit.TestResultFilter."""
from datetime import datetime
+from io import BytesIO
import os
import subprocess
import sys
-from subunit import iso8601
import unittest
-from testtools import TestCase
from testtools.compat import _b
-try:
- from testtools.compat import BytesIO
-except ImportError:
- from io import BytesIO
+from testtools import TestCase
from testtools.testresult.doubles import ExtendedTestResult, StreamResult
import subunit
+from subunit import iso8601
from subunit.test_results import make_tag_filter, TestResultFilter
from subunit import ByteStreamToStreamResult, StreamResultToBytes
diff --git a/python/subunit/tests/test_subunit_stats.py b/python/subunit/tests/test_subunit_stats.py
index 9faf24d..46be5c2 100644
--- a/python/subunit/tests/test_subunit_stats.py
+++ b/python/subunit/tests/test_subunit_stats.py
@@ -6,7 +6,7 @@
# license at the users choice. A copy of both licenses are available in the
# project source as Apache-2.0 and BSD. You may not use this file except in
# compliance with one of these two licences.
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -16,13 +16,11 @@
"""Tests for subunit.TestResultStats."""
+from io import BytesIO
+from io import StringIO
import unittest
from testtools.compat import _b
-try:
- from testtools.compat import BytesIO, StringIO
-except ImportError:
- from io import BytesIO, StringIO
import subunit
diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py
index a498b33..74cb1ce 100644
--- a/python/subunit/tests/test_test_protocol.py
+++ b/python/subunit/tests/test_test_protocol.py
@@ -16,16 +16,14 @@
import datetime
import io
+from io import BytesIO
+from io import StringIO
import os
import tempfile
import unittest
from testtools import PlaceHolder, skipIf, TestCase, TestResult
from testtools.compat import _b, _u
-try:
- from testtools.compat import BytesIO, StringIO
-except ImportError:
- from io import BytesIO, StringIO
from testtools.content import Content, TracebackContent, text_content
from testtools.content_type import ContentType
try:
diff --git a/python/subunit/tests/test_test_results.py b/python/subunit/tests/test_test_results.py
index a0efa80..31fd0ac 100644
--- a/python/subunit/tests/test_test_results.py
+++ b/python/subunit/tests/test_test_results.py
@@ -16,18 +16,15 @@
import csv
import datetime
+from io import StringIO
import sys
import unittest
from testtools import TestCase
-try:
- from testtools.compat import StringIO
-except ImportError:
- from io import StringIO
from testtools.content import (
text_content,
TracebackContent,
- )
+)
from testtools.testresult.doubles import ExtendedTestResult
import subunit