Skip to content

Commit 255e2d8

Browse files
author
Matthias Koeppe
committed
sage -fixdoctests: Handle ImportError too
1 parent 7302ff3 commit 255e2d8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/bin/sage-fixdoctests

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,12 @@ def process_block(block, src_in_lines, file_optional_tags):
189189
return
190190

191191
# Error testing.
192-
if m := re.search(r"ModuleNotFoundError: No module named '([^']*)'", block):
193-
module = m.group(1)
192+
if m := re.search(r"(?:ModuleNotFoundError: No module named|ImportError: cannot import name '([^']*)' from) '([^']*)'", block):
193+
if m.group(1):
194+
# "ImportError: cannot import name 'function_field_polymod' from 'sage.rings.function_field' (unknown location)"
195+
module = m.group(2) + '.' + m.group(1)
196+
else:
197+
module = m.group(2)
194198
asked_why = re.search('#.*(why|explain)', src_in_lines[first_line_num - 1])
195199
optional = module_feature(module)
196200
if optional and optional.name not in file_optional_tags:

0 commit comments

Comments
 (0)