Skip to content

Commit cdf4887

Browse files
committed
Whoops, need native strings.
1 parent f5cc7cc commit cdf4887

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

jsonschema/compat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
if PY3:
1313
zip = zip
1414
from functools import lru_cache
15-
from io import StringIO
15+
from io import StringIO as NativeIO
1616
from urllib.parse import (
1717
unquote, urljoin, urlunsplit, SplitResult, urlsplit as _urlsplit
1818
)
@@ -22,7 +22,7 @@
2222
iteritems = operator.methodcaller("items")
2323
else:
2424
from itertools import izip as zip # noqa
25-
from StringIO import StringIO
25+
from io import BytesIO as NativeIO
2626
from urlparse import (
2727
urljoin, urlunsplit, SplitResult, urlsplit as _urlsplit # noqa
2828
)

jsonschema/tests/test_cli.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
from io import BytesIO
21
from unittest import TestCase
32
import json
43

54
from jsonschema import Draft4Validator, ValidationError, cli
6-
from jsonschema.compat import StringIO
5+
from jsonschema.compat import NativeIO
76
from jsonschema.exceptions import SchemaError
87

98

@@ -42,7 +41,7 @@ def fake_open(self, path):
4241
contents = {}
4342
else:
4443
self.fail("What is {!r}".format(path))
45-
return BytesIO(json.dumps(contents))
44+
return NativeIO(json.dumps(contents))
4645

4746
def test_find_validator_by_fully_qualified_object_name(self):
4847
arguments = cli.parse_args(
@@ -68,7 +67,7 @@ def test_find_validator_in_jsonschema(self):
6867

6968
class TestCLI(TestCase):
7069
def test_draft3_schema_draft4_validator(self):
71-
stdout, stderr = StringIO(), StringIO()
70+
stdout, stderr = NativeIO(), NativeIO()
7271
with self.assertRaises(SchemaError):
7372
cli.run(
7473
{
@@ -88,7 +87,7 @@ def test_draft3_schema_draft4_validator(self):
8887
)
8988

9089
def test_successful_validation(self):
91-
stdout, stderr = StringIO(), StringIO()
90+
stdout, stderr = NativeIO(), NativeIO()
9291
exit_code = cli.run(
9392
{
9493
"validator": fake_validator(),
@@ -105,7 +104,7 @@ def test_successful_validation(self):
105104

106105
def test_unsuccessful_validation(self):
107106
error = ValidationError("I am an error!", instance=1)
108-
stdout, stderr = StringIO(), StringIO()
107+
stdout, stderr = NativeIO(), NativeIO()
109108
exit_code = cli.run(
110109
{
111110
"validator": fake_validator([error]),
@@ -126,7 +125,7 @@ def test_unsuccessful_validation_multiple_instances(self):
126125
ValidationError("8", instance=1),
127126
]
128127
second_errors = [ValidationError("7", instance=2)]
129-
stdout, stderr = StringIO(), StringIO()
128+
stdout, stderr = NativeIO(), NativeIO()
130129
exit_code = cli.run(
131130
{
132131
"validator": fake_validator(first_errors, second_errors),

0 commit comments

Comments
 (0)