File: test_pweave.py

package info (click to toggle)
python-pweave 0.30.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 5,064 kB
  • sloc: python: 30,281; makefile: 167
file content (75 lines) | stat: -rw-r--r-- 2,498 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
"""Integration test pweave by comparing output to a known good
reference.

N.B. can't use anything in the .mdw that will give different
outputs each time. For example, setting term=True and then
calling figure() will output a matplotlib figure reference. This
has a memory pointer that changes every time.
"""

import unittest
import os
import pweave
try:
    from tests._frameworkForTests import RegressionTest
except:
    from _frameworkForTests import RegressionTest

class WeaveTest(RegressionTest):
    def _testGenerator(name, doctype, filename, kwargs={}, python={2, 3}):
        def testMethod(self):
            self.TESTDIR = os.path.join('weave', doctype)
            infile = self.absPathTo(filename + 'w')
            self.setNewOutfile(filename)

            pweave.weave(infile, doctype=doctype,
                output=self.absPathTo(filename),
                **kwargs)

            basename, _, ext = filename.rpartition('.')
            self.REFERENCE = self.absPathTo(basename + '_REF.' + ext)
            self.assertSameAsReference()

        testMethod.__name__ = name
        return testMethod

    _tests = {
              'Simple': (['pandoc', 'simple.md'], {}),
              'ClassInMultipleChunksUsingContinueOption': (['pandoc', 'ar_yw.md'], {}),
              'InlineCode': (['pandoc', 'inline_chunks.md'], {}),
              #'TerminalEmulation': (['tex', 'term_test.tex'], {}), Needs inspection
              'FIR_FilterExampleTex': (['tex', 'FIR_design_verb.tex'], {}),
              'WrapAndCodeOutput': (['texminted', 'wrap_test.tex'], {})
              }



class ConvertTest(RegressionTest):
    """Test pweave-convert
    """
    TESTDIR = 'convert'

    def _testGenerator(name, infile, informat, outformat, outext, python={2, 3}):
        def testMethod(self):
            basename, _, _ = infile.rpartition('.')
            outfile = basename + '.' + outext
            self.setNewOutfile(outfile)

            pweave.convert(self.absPathTo(infile),
                           informat=informat,
                           outformat=outformat)

            self.REFERENCE = self.absPathTo(basename + '_REF.' + outext)
            self.assertSameAsReference()

        testMethod.__name__ = name
        return testMethod

    _tests = {
              'Convert': (['convert_test.txt', 'script', 'noweb', 'Pnw'], {}),
              'Nbformat': (['simple.mdw', 'noweb', 'notebook', 'ipynb'], {}),
             }


if __name__ == '__main__':
    unittest.main()