diff options
author | Gabe Fierro <gtfierro@cs.berkeley.edu> | 2022-01-13 16:47:49 -0700 |
---|---|---|
committer | Gabe Fierro <gtfierro@cs.berkeley.edu> | 2022-01-13 16:47:49 -0700 |
commit | 93e6d0d88f3575dab4fee2c30feb6ac7f523e1c8 (patch) | |
tree | 39a3410c07a97557aac50b25084a8fbc528ffcc2 | |
parent | eda9a6d0658a4e3f9ef43910bac42488f25826ce (diff) | |
download | rdflib-93e6d0d88f3575dab4fee2c30feb6ac7f523e1c8.tar.gz |
use simplified implementation of function; change test name to be more descriptive
-rw-r--r-- | rdflib/plugins/sparql/operators.py | 14 | ||||
-rw-r--r-- | test/test_issue274.py | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/rdflib/plugins/sparql/operators.py b/rdflib/plugins/sparql/operators.py index c3caab71..18b96658 100644 --- a/rdflib/plugins/sparql/operators.py +++ b/rdflib/plugins/sparql/operators.py @@ -612,11 +612,17 @@ def custom_function(uri, override=False, raw=False): return decorator -def unregister_custom_function(uri, func): - if _CUSTOM_FUNCTIONS.get(uri, (None, None))[0] != func: - warnings.warn("This function is not registered as %s" % uri.n3()) - else: +def unregister_custom_function(uri, func=None): + """ + The 'func' argument is included for compatibility with existing code. + A previous implementation checked that the function associated with + the given uri was actually 'func', but this is not necessary as the + uri should uniquely identify the function. + """ + if _CUSTOM_FUNCTIONS.get(uri): del _CUSTOM_FUNCTIONS[uri] + else: + warnings.warn("This function is not registered as %s" % uri.n3()) def Function(e, ctx): diff --git a/test/test_issue274.py b/test/test_issue274.py index 38138d8d..fd2b3e14 100644 --- a/test/test_issue274.py +++ b/test/test_issue274.py @@ -187,7 +187,7 @@ class TestCustom(TestCase): def test_register_override(self): register_custom_function(EX.f, self.f, override=True) - def test_wrong_unregister_fails(self): + def test_wrong_unregister_warns(self): with pytest.warns(UserWarning): unregister_custom_function(EX.f, lambda x, y: None) |