Show More
@@ -521,6 +521,26 b' def escapef(m):' | |||||
521 | def stringescape(s): |
|
521 | def stringescape(s): | |
522 | return escapesub(escapef, s) |
|
522 | return escapesub(escapef, s) | |
523 |
|
523 | |||
|
524 | def transformtst(lines): | |||
|
525 | inblock = False | |||
|
526 | for l in lines: | |||
|
527 | if inblock: | |||
|
528 | if l.startswith(' $ '): | |||
|
529 | inblock = False | |||
|
530 | yield ' > EOF\n' | |||
|
531 | yield l | |||
|
532 | else: | |||
|
533 | yield ' > ' + l[2:] | |||
|
534 | else: | |||
|
535 | if l.startswith(' >>> '): | |||
|
536 | inblock = True | |||
|
537 | yield ' $ %s -m heredoctest <<EOF\n' % PYTHON | |||
|
538 | yield ' > ' + l[2:] | |||
|
539 | else: | |||
|
540 | yield l | |||
|
541 | if inblock: | |||
|
542 | yield ' > EOF\n' | |||
|
543 | ||||
524 | def tsttest(test, wd, options, replacements): |
|
544 | def tsttest(test, wd, options, replacements): | |
525 | t = open(test) |
|
545 | t = open(test) | |
526 | out = [] |
|
546 | out = [] | |
@@ -530,7 +550,7 b' def tsttest(test, wd, options, replaceme' | |||||
530 | pos = prepos = -1 |
|
550 | pos = prepos = -1 | |
531 | after = {} |
|
551 | after = {} | |
532 | expected = {} |
|
552 | expected = {} | |
533 | for n, l in enumerate(t): |
|
553 | for n, l in enumerate(transformtst(t)): | |
534 | if not l.endswith('\n'): |
|
554 | if not l.endswith('\n'): | |
535 | l += '\n' |
|
555 | l += '\n' | |
536 | if l.startswith(' $ '): # commands |
|
556 | if l.startswith(' $ '): # commands | |
@@ -833,7 +853,7 b' def runone(options, test):' | |||||
833 | refout = None # to match "out is None" |
|
853 | refout = None # to match "out is None" | |
834 | elif os.path.exists(ref): |
|
854 | elif os.path.exists(ref): | |
835 | f = open(ref, "r") |
|
855 | f = open(ref, "r") | |
836 | refout = splitnewlines(f.read()) |
|
856 | refout = list(transformtst(splitnewlines(f.read()))) | |
837 | f.close() |
|
857 | f.close() | |
838 | else: |
|
858 | else: | |
839 | refout = [] |
|
859 | refout = [] |
General Comments 0
You need to be logged in to leave comments.
Login now