Skip to content

Commit

Permalink
Fix function-lookup() to set a copy of the context
Browse files Browse the repository at this point in the history
  • Loading branch information
brunato committed Feb 9, 2024
1 parent 8e7e389 commit a1879e2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions elementpath/xpath30/_xpath30_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,7 @@ def evaluate_function_lookup_function(self, context=None):
return []

func.namespace = qname.namespace
func.context = copy(context)
return func


Expand Down
13 changes: 12 additions & 1 deletion tests/execute_w3c_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@
'fn-function-lookup__fn-function-lookup-764', # Error code should be FOQM0001
}

SKIP_XP20 = {
'fn-subsequence__fn-subsequence-mix-args-026', # fn:tail is XP30+
}

# Tests that can be run only with lxml.etree
LXML_ONLY = {
# parse of comments or PIs required
Expand Down Expand Up @@ -210,6 +214,7 @@
'prod-EQName__eqname-018',
'prod-EQName__eqname-023',
'prod-NamedFunctionRef__function-literal-262',
'fn-format-number__numberformat83',

# XML declaration
'fn-serialize__serialize-xml-029b',
Expand Down Expand Up @@ -802,8 +807,10 @@ def run_xpath_test(self, verbose=1, with_context=True, with_xpath_nodes=False):

if '.' in environment.sources:
root = environment.sources['.'].xml
root_uri = environment.sources['.'].uri
else:
root = self.etree.XML("<empty/>")
root_uri = None

if any(k.startswith('$') for k in environment.sources):
variables.update(
Expand Down Expand Up @@ -841,7 +848,7 @@ def run_xpath_test(self, verbose=1, with_context=True, with_xpath_nodes=False):
if self.calendar:
kwargs['default_calendar'] = self.calendar

context = XPathContext(root=root, **kwargs)
context = XPathContext(root=root, uri=root_uri, **kwargs)

try:
if with_xpath_nodes:
Expand Down Expand Up @@ -1559,6 +1566,10 @@ def main():
count_skip += 1
continue

if test_case.name in SKIP_XP20 and not args.xp30 and not args.xp31:
count_skip += 1
continue

if not args.use_lxml and test_case.name in LXML_ONLY:
count_skip += 1
continue
Expand Down

0 comments on commit a1879e2

Please sign in to comment.