diff --git a/osp/core/ontology/namespace.py b/osp/core/ontology/namespace.py index 24cfa482..e92049e9 100644 --- a/osp/core/ontology/namespace.py +++ b/osp/core/ontology/namespace.py @@ -187,9 +187,10 @@ def _do_get(self, name, _case_sensitive, _force_by_iri): iri = rdflib.URIRef(str(self._iri) + iri_suffix) try: return self._namespace_registry.from_iri(iri, _name=name) - except ValueError: - return self._get_case_insensitive(name) - return self._get_case_insensitive(name) + except KeyError as e: + if not _case_sensitive: + return self._get_case_insensitive(name) + raise e def _get_case_insensitive(self, name): """Get by trying alternative naming convention of given name. diff --git a/tests/test_case_insensitivity.py b/tests/test_case_insensitivity.py index 35fa206d..9d3a685a 100644 --- a/tests/test_case_insensitivity.py +++ b/tests/test_case_insensitivity.py @@ -26,6 +26,9 @@ def test_get_case_insensitive_alternative(self): self.assertEqual(alt("some_entity", False), "SOME_ENTITY") self.assertEqual(alt("SOME_ENTITY", False), "SOME_ENTITY") + from osp.core.namespaces import cuba + self.assertEqual(cuba.wrapper, cuba.Wrapper) + if __name__ == "__main__": unittest.main()