# HG changeset patch
# User J. H. Palmieri <palmieri@math.washington.edu>
# Date 1315605479 25200
# Node ID 036a515b86cb02c80c7dc5cbde65ea0d5d3bf080
# Parent b8a5292b124243e87dbec5c2f42aade98612c92b
#10952: make tolerance failures print more concisely
and also include the line number.
diff --git a/sage-doctest b/sage-doctest
|
a
|
b
|
def doc_preparse(s): |
| 279 | 279 | for L in s.splitlines(): |
| 280 | 280 | if not L.strip(): |
| 281 | 281 | if has_tolerance: |
| 282 | | t.append(close_tolerance(c)) |
| | 282 | t.append(close_tolerance(c) + old_cmd) |
| 283 | 283 | has_tolerance = False |
| 284 | 284 | |
| 285 | 285 | begin = L.lstrip()[:5] |
| 286 | 286 | comment = '' |
| 287 | 287 | if begin == 'sage:': |
| 288 | 288 | if has_tolerance: |
| 289 | | t.append(close_tolerance(c)) |
| | 289 | # old_cmd contains the command being tested along with |
| | 290 | # the line number. |
| | 291 | t.append(close_tolerance(c) + old_cmd) |
| 290 | 292 | c, comment = comment_modifier(L) |
| 291 | 293 | last_prompt_comment = comment |
| 292 | 294 | line = '' |
| … |
… |
def doc_preparse(s): |
| 316 | 318 | # and an empty line, to ignore the output given in the test |
| 317 | 319 | line += '\n' + ' '*i + 'ignore ...\n' |
| 318 | 320 | if has_tolerance: |
| | 321 | # save the current command along with the line number |
| | 322 | try: |
| | 323 | idx = line.index('###_sage"line') |
| | 324 | old_cmd = line[idx:] |
| | 325 | except IndexError: |
| | 326 | old_cmd = '' |
| 319 | 327 | line += "\n>>> check_with_tolerance('''" |
| 320 | 328 | t.append(line) |
| 321 | 329 | |
| … |
… |
def post_process(s, file, tmpname): |
| 667 | 675 | j = s[i:].find('###line') |
| 668 | 676 | s = s[:k] + ', ' + s[i+j+3:] |
| 669 | 677 | i = s.find("Failed example:") |
| | 678 | if i != -1: |
| | 679 | t = s[:i] |
| | 680 | else: |
| | 681 | t = s |
| | 682 | if t.find('check_with_tolerance') != -1: |
| | 683 | j = s.find('Exception raised') |
| | 684 | ass = 'AssertionError: ' |
| | 685 | k = s.find(ass) |
| | 686 | s = s[:j] + s[k+len(ass):] |
| | 687 | i = s.find("Failed example:") |
| 670 | 688 | cnt += 1 |
| 671 | 689 | if cnt > 1000: |
| 672 | 690 | break |