Code Duplication    Length = 27-32 lines in 2 locations

sdoc/SDoc.py 2 locations

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