Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit 1efb0bc

Browse files
author
Jonathan Kliem
committed
fixdoctests can treat multiline examples
1 parent ca088c9 commit 1efb0bc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/bin/sage-fixdoctests

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ for block in doctests:
6262
comma = block.find(', in ') # we try to extract the line number which gives the test failure
6363
if line == -1 or comma==-1: continue # but if something goes wrong we give up
6464
line_num=eval(block[line+5:comma])
65+
66+
# Take care of multiline examples.
67+
if 'Expected' in block:
68+
i1 = block.index('Failed example')
69+
i2 = block.index('Expected')
70+
example_len = block[i1:i2].count('\n') - 1
71+
line_num += example_len - 1
72+
6573
if 'Expected nothing' in block:
6674
exp = block.find('Expected nothing')
6775
block='\n'+block[exp+17:] # so that split('\nGot:\n') does not fail below

0 commit comments

Comments
 (0)