From 22701dc6526433201d2781b77566a6dba42768a8 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Fri, 27 Feb 2015 19:53:54 -0500 Subject: [PATCH] Fix test failures --- jsonschema/tests/test_validators.py | 4 ++-- jsonschema/validators.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/jsonschema/tests/test_validators.py b/jsonschema/tests/test_validators.py index 2b14372..b3512ed 100644 --- a/jsonschema/tests/test_validators.py +++ b/jsonschema/tests/test_validators.py @@ -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: diff --git a/jsonschema/validators.py b/jsonschema/validators.py index 8f48062..d0431f3 100644 --- a/jsonschema/validators.py +++ b/jsonschema/validators.py @@ -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]