Skip to content

Commit 311ca30

Browse files
committed
Improve check_xpath
1 parent 898e50c commit 311ca30

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/test_builders/test_build_html.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ def check_xpath(etree, fname, path, check, be_found=True):
3838
nodes = list(etree.findall(path))
3939
if check is None:
4040
assert nodes == [], ('found any nodes matching xpath '
41-
'%r in file %s' % (path, fname))
41+
f'{path!r} in file {fname}')
4242
return
4343
else:
4444
assert nodes != [], ('did not find any node matching xpath '
45-
'%r in file %s' % (path, fname))
45+
f'{path!r} in file {fname}')
4646
if callable(check):
4747
check(nodes)
4848
elif not check:
@@ -65,9 +65,9 @@ def get_text(node):
6565
if all(not rex.search(get_text(node)) for node in nodes):
6666
return
6767

68-
raise AssertionError('%r not found in any node matching '
69-
'path %s in %s: %r' % (check, path, fname,
70-
[node.text for node in nodes]))
68+
msg = (f'{check!r} not found in any node matching '
69+
f'{path!r} in file {fname}: {[node.text for node in nodes]!r}')
70+
raise AssertionError(msg)
7171

7272

7373
@pytest.mark.sphinx('html', testroot='warnings', freshenv=True)

0 commit comments

Comments
 (0)