Fix test failures

This commit is contained in:
Daniel Nephin 2015-02-27 19:53:54 -05:00
parent 2fda1556ef
commit 22701dc652
2 changed files with 11 additions and 6 deletions

View File

@ -815,7 +815,7 @@ class TestRefResolver(unittest.TestCase):
def test_it_can_construct_a_base_uri_from_a_schema(self):
schema = {"id" : "foo"}
resolver = RefResolver.from_schema(schema)
self.assertEqual(resolver.base_uri, "foo")
self.assertEqual(resolver.base_uri.url, "foo")
with resolver.resolving("") as resolved:
self.assertEqual(resolved, schema)
with resolver.resolving("#") as resolved:
@ -828,7 +828,7 @@ class TestRefResolver(unittest.TestCase):
def test_it_can_construct_a_base_uri_from_a_schema_without_id(self):
schema = {}
resolver = RefResolver.from_schema(schema)
self.assertEqual(resolver.base_uri, "")
self.assertEqual(resolver.base_uri.url, "")
with resolver.resolving("") as resolved:
self.assertEqual(resolved, schema)
with resolver.resolving("#") as resolved:

View File

@ -229,7 +229,7 @@ class RefResolver(object):
:argument str base_uri: URI of the referring document
:argument referrer: the actual referring document
:argument dict store: a mapping from URIs (without fragments!) to documents to cache
:argument dict store: a mapping from URIs to documents to cache
:argument bool cache_remote: whether remote refs should be cached after
first resolution
:argument dict handlers: a mapping from URI schemes to functions that
@ -275,7 +275,7 @@ class RefResolver(object):
scope = urldefrag(scope)
self.resolution_scope = DefragResult(
urljoin(old_scope.url, scope.url, allow_fragments=False)
if scope.url else old_scope.url,
if scope.url else old_scope.url,
scope.fragment
)
@ -294,8 +294,13 @@ class RefResolver(object):
ref = urldefrag(ref)
url = urljoin(self.resolution_scope.url, ref.url, allow_fragments=False) \
if ref.url else self.resolution_scope.url
if ref.url:
url = urljoin(
self.resolution_scope.url,
ref.url,
allow_fragments=False)
else:
url = self.resolution_scope.url
try:
document = self.store[url]