Skip to content

Commit 484510f

Browse files
committed
chore: Tear out StringIO hacks
1 parent 5d93b60 commit 484510f

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

test/_common.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
"""Common support for the test cases."""
2-
import io as StringIO
32
import time
4-
from io import BytesIO
3+
from io import BytesIO, StringIO
54
from os.path import join
65
from urllib.request import OpenerDirector
76

87
import musicbrainzngs
9-
from musicbrainzngs import compat
108

119

1210
class FakeOpener(OpenerDirector):
@@ -28,7 +26,7 @@ def open(self, request, body=None):
2826
raise self.exception
2927

3028
if isinstance(self.response, str):
31-
return StringIO.StringIO(self.response)
29+
return StringIO(self.response)
3230
else:
3331
return BytesIO(self.response)
3432

@@ -67,7 +65,7 @@ def restore(self):
6765
time.sleep = self.orig['sleep']
6866

6967
def open_and_parse_test_data(datadir, filename):
70-
""" Opens an XML file dumped from the MusicBrainz web service and returns
68+
"""Opens an XML file dumped from the MusicBrainz web service and returns
7169
the parses it.
7270
7371
:datadir: The directory containing the file

test/test_caa.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
from io import StringIO
23
from urllib.error import HTTPError
34

45
import musicbrainzngs
@@ -33,7 +34,7 @@ def test_get_release_group_list(self):
3334
def test_list_none(self):
3435
""" When CAA gives a 404 error, pass it through."""
3536

36-
exc = HTTPError("", 404, "", "", _common.StringIO.StringIO(""))
37+
exc = HTTPError("", 404, "", "", StringIO(""))
3738
self.opener = _common.FakeOpener(exception=musicbrainzngs.ResponseError(cause=exc))
3839
musicbrainzngs.compat.build_opener = lambda *args: self.opener
3940
try:
@@ -43,7 +44,7 @@ def test_list_none(self):
4344
self.assertEqual(e.cause.code, 404)
4445

4546
def test_list_baduuid(self):
46-
exc = HTTPError("", 400, "", "", _common.StringIO.StringIO(""))
47+
exc = HTTPError("", 400, "", "", StringIO(""))
4748
self.opener = _common.FakeOpener(exception=musicbrainzngs.ResponseError(cause=exc))
4849
musicbrainzngs.compat.build_opener = lambda *args: self.opener
4950
try:

test/test_collection.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
from io import StringIO
23
from urllib.error import HTTPError
34

45
import musicbrainzngs
@@ -80,7 +81,7 @@ def local_mb_request(path, method='GET',
8081
def test_no_collection(self):
8182
""" If a collection doesn't exist, you get a 404 """
8283

83-
exc = HTTPError("", 404, "", "", _common.StringIO.StringIO(""))
84+
exc = HTTPError("", 404, "", "", StringIO(""))
8485
self.opener = _common.FakeOpener(exception=musicbrainzngs.ResponseError(cause=exc))
8586
musicbrainzngs.compat.build_opener = lambda *args: self.opener
8687
try:
@@ -93,7 +94,7 @@ def test_private_collection(self):
9394
""" If you ask for a collection that is private, you should
9495
get a 401"""
9596

96-
exc = HTTPError("", 401, "", "", _common.StringIO.StringIO(""))
97+
exc = HTTPError("", 401, "", "", StringIO(""))
9798
self.opener = _common.FakeOpener(exception=musicbrainzngs.AuthenticationError(cause=exc))
9899
musicbrainzngs.compat.build_opener = lambda *args: self.opener
99100
try:

0 commit comments

Comments
 (0)