|
@@ 323-354 (lines=32) @@
|
| 320 |
|
return output, sdoc2 |
| 321 |
|
|
| 322 |
|
# ------------------------------------------------------------------------------------------------------------------ |
| 323 |
|
def test_sdoc2(self, main_filename): |
| 324 |
|
""" |
| 325 |
|
Parses a SDoc document and returns a tuple with the stdout and the resulting SDoc2 document. |
| 326 |
|
|
| 327 |
|
:param str main_filename: The name of the file with then main SDoc1 document. |
| 328 |
|
|
| 329 |
|
:rtype: (str,str) |
| 330 |
|
""" |
| 331 |
|
self._create_node_store() |
| 332 |
|
self._import_nodes() |
| 333 |
|
self._import_formatters() |
| 334 |
|
|
| 335 |
|
old_stdout, sys.stdout = sys.stdout, StringIO() |
| 336 |
|
|
| 337 |
|
temp_filename = main_filename + '.sdoc2' |
| 338 |
|
interpreter1 = SDoc1Interpreter() |
| 339 |
|
interpreter1.process(main_filename, temp_filename) |
| 340 |
|
|
| 341 |
|
interpreter2 = SDoc2Interpreter() |
| 342 |
|
interpreter2.process(temp_filename) |
| 343 |
|
|
| 344 |
|
sdoc.sdoc2.node_store.number_numerable() |
| 345 |
|
|
| 346 |
|
output = sys.stdout.getvalue().strip() |
| 347 |
|
sys.stdout = old_stdout |
| 348 |
|
|
| 349 |
|
with open(temp_filename, 'rt') as fd: |
| 350 |
|
sdoc2 = fd.read() |
| 351 |
|
|
| 352 |
|
os.unlink(temp_filename) |
| 353 |
|
|
| 354 |
|
return output, sdoc2 |
| 355 |
|
|
| 356 |
|
# ------------------------------------------------------------------------------------------------------------------ |
| 357 |
|
def main(self): |
|
@@ 294-320 (lines=27) @@
|
| 291 |
|
sdoc.sdoc2.node_store.generate(self._formatter.one_file, self._formatter.file_per_chapter) |
| 292 |
|
|
| 293 |
|
# ------------------------------------------------------------------------------------------------------------------ |
| 294 |
|
def test_sdoc1(self, main_filename): |
| 295 |
|
""" |
| 296 |
|
Parses a SDoc document and returns a tuple with the stdout and the resulting SDoc2 document. |
| 297 |
|
|
| 298 |
|
:param str main_filename: The name of the file with then main SDoc1 document. |
| 299 |
|
|
| 300 |
|
:rtype: (str,str) |
| 301 |
|
""" |
| 302 |
|
self._create_node_store() |
| 303 |
|
self._import_nodes() |
| 304 |
|
self._import_formatters() |
| 305 |
|
|
| 306 |
|
old_stdout, sys.stdout = sys.stdout, StringIO() |
| 307 |
|
|
| 308 |
|
temp_filename = main_filename + '.sdoc2' |
| 309 |
|
interpreter1 = SDoc1Interpreter() |
| 310 |
|
interpreter1.process(main_filename, temp_filename) |
| 311 |
|
|
| 312 |
|
output = sys.stdout.getvalue().strip() |
| 313 |
|
sys.stdout = old_stdout |
| 314 |
|
|
| 315 |
|
with open(temp_filename, 'rt') as fd: |
| 316 |
|
sdoc2 = fd.read() |
| 317 |
|
|
| 318 |
|
os.unlink(temp_filename) |
| 319 |
|
|
| 320 |
|
return output, sdoc2 |
| 321 |
|
|
| 322 |
|
# ------------------------------------------------------------------------------------------------------------------ |
| 323 |
|
def test_sdoc2(self, main_filename): |