File: test_strip_elements_with_class.py

package info (click to toggle)
python-docutils 0.16%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 8,864 kB
  • sloc: python: 45,783; lisp: 14,475; xml: 1,785; javascript: 1,032; sh: 140; makefile: 111
file content (62 lines) | stat: -rw-r--r-- 1,255 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
#! /usr/bin/env python

# $Id: test_strip_elements_with_class.py 8385 2019-09-06 13:16:07Z milde $
# Author: Guenter Milde <milde@users.sf.net>
# Copyright: This module has been placed in the public domain.

"""
Tests for docutils.transforms.universal.StripClassesAndElements.
"""
from __future__ import absolute_import

from . import DocutilsTestSupport
from docutils.parsers.rst import Parser
from docutils.transforms.universal import StripClassesAndElements

def suite():
    parser = Parser()
    s = DocutilsTestSupport.TransformTestSuite(parser,
            suite_settings={'strip_elements_with_classes': ['spam', 'no-ham'],
                            'strip_classes': ['spam', 'noise']})
    s.generateTests(totest)
    return s

totest = {}

totest['strip_spam'] = ((StripClassesAndElements,), [
["""\
not classy

.. class:: spam

this is spam

.. class:: ham noise

this is ham

.. code::
   :class: spam
   
   print("spam")
   
.. image:: spam.jpg
   :class: spam

this is not ham
""",
"""\
<document source="test data">
    <paragraph>
        not classy
    <paragraph classes="ham">
        this is ham
    <paragraph>
        this is not ham
"""],
])


if __name__ == '__main__':
    import unittest
    unittest.main(defaultTest='suite')