diff options
-rw-r--r-- | jsonschema/compat.py | 4 | ||||
-rw-r--r-- | jsonschema/tests/test_validators.py | 8 |
2 files changed, 3 insertions, 9 deletions
diff --git a/jsonschema/compat.py b/jsonschema/compat.py index 7c63a71..93492f9 100644 --- a/jsonschema/compat.py +++ b/jsonschema/compat.py @@ -22,7 +22,7 @@ if PY3: from urllib.parse import ( unquote, urljoin, urlunsplit, SplitResult, urlsplit as _urlsplit ) - from urllib.request import urlopen + from urllib.request import pathname2url, urlopen str_types = str, int_types = int, iteritems = operator.methodcaller("items") @@ -32,7 +32,7 @@ else: from urlparse import ( urljoin, urlunsplit, SplitResult, urlsplit as _urlsplit # noqa ) - from urllib import unquote # noqa + from urllib import pathname2url, unquote # noqa import urllib2 # noqa def urlopen(*args, **kwargs): return contextlib.closing(urllib2.urlopen(*args, **kwargs)) diff --git a/jsonschema/tests/test_validators.py b/jsonschema/tests/test_validators.py index 0563d1a..b4ce666 100644 --- a/jsonschema/tests/test_validators.py +++ b/jsonschema/tests/test_validators.py @@ -20,16 +20,10 @@ from jsonschema import ( _types, validators, ) -from jsonschema.compat import PY3 +from jsonschema.compat import PY3, pathname2url from jsonschema.tests.compat import mock -if PY3: - from urllib.request import pathname2url -else: - from urllib import pathname2url - - def startswith(validator, startswith, instance, schema): if not instance.startswith(startswith): yield ValidationError(u"Whoops!") |