4 Author: grubert@users.sourceforge.net
7 Split docutils/tools/test.txt up to test one by one.
10 import sys
, os
, os
.path
13 test_filename
= sys
.argv
[1]
15 # run from sandbox subdirectory.
16 test_filename
= "../../tools/test.txt"
18 if not os
.path
.exists(test_filename
):
19 print "Testfile not found:", test_filename
22 print "Using file:", test_filename
25 def __init__(self
,test_dir
="test"):
28 self
._test
_dir
= test_dir
29 self
._test
_file
= "from_test_txt"
36 self
._file
= open("%s/%s-%02d.txt.new"
37 %(self
._test
_dir
,self
._test
_file
,self
._file
_cnt
),"w")
38 def write_line(self
,str):
39 self
._file
.write(str+"\n")
47 section_one
= 1 # header plus first section into first file
48 for line
in open(test_filename
).readlines():
49 line
= line
.rstrip() # remove end of line
50 # we split on "------" sections.
51 if ((len(line
)>0)and(line
== "-"*(len(line
)))and(len(line
)==len(line_before
))):
54 print section_one
,line_before
,line
56 if not (type(line_before
)==type(-1)):
57 # special treatment of start block
58 out
.write_line(line_before
)