diff options
author | Daniel Nephin <dnephin@gmail.com> | 2015-03-15 17:51:07 -0400 |
---|---|---|
committer | Daniel Nephin <dnephin@gmail.com> | 2015-03-15 17:51:07 -0400 |
commit | 7241db0d5e0be9a43acde2743f68a5182b3f97ed (patch) | |
tree | 6a4e5e590dc4a050a1b5ef86f38011c72f93fb80 | |
parent | ee1a256fc856a616940fb1eddcb3f4d8f7cb2f22 (diff) | |
download | jsonschema-7241db0d5e0be9a43acde2743f68a5182b3f97ed.tar.gz |
Fix base_uri backwards compatibility.
-rw-r--r-- | jsonschema/tests/test_validators.py | 2 | ||||
-rw-r--r-- | jsonschema/validators.py | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/jsonschema/tests/test_validators.py b/jsonschema/tests/test_validators.py index 1f03294..cc4bea8 100644 --- a/jsonschema/tests/test_validators.py +++ b/jsonschema/tests/test_validators.py @@ -810,6 +810,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.resolution_scope, "foo") with resolver.resolving("") as resolved: self.assertEqual(resolved, schema) @@ -823,6 +824,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.resolution_scope, "") with resolver.resolving("") as resolved: self.assertEqual(resolved, schema) diff --git a/jsonschema/validators.py b/jsonschema/validators.py index c84a3db..8f35d2b 100644 --- a/jsonschema/validators.py +++ b/jsonschema/validators.py @@ -288,6 +288,11 @@ class RefResolver(object): def resolution_scope(self): return self._scopes_stack[-1] + # backwards compatibility + @property + def base_uri(self): + uri, _ = urldefrag(self.resolution_scope) + return uri # Deprecated, this function is no longer used, but is preserved for # backwards compatibility |