diff options
| author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2022-02-03 18:03:47 +0000 |
|---|---|---|
| committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2022-02-03 18:03:47 +0000 |
| commit | ef9b5c1d4b15d78b8c69e045a68759ff22a5891d (patch) | |
| tree | 0f526351fde6b3f786ee16cd9f38f48fbb74725b /docutils/test/test_transforms | |
| parent | 1cec9a96b49a74c08b973361ed2a16cbc1676a01 (diff) | |
| download | docutils-ef9b5c1d4b15d78b8c69e045a68759ff22a5891d.tar.gz | |
Fix FilterMessages transform [bug:#435].
The "Messages" transform no longer tests for to-be-ignored messages
but inserts all `system-messages` without parent into a
"System Messages" section.
This allows the "FilterMessages" transform to find and convert
matching `problematic` nodes (but now it also has to remove the
"System Messages" section if empty).
git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8997 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/test/test_transforms')
| -rw-r--r-- | docutils/test/test_transforms/test_filter_messages.py | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/docutils/test/test_transforms/test_filter_messages.py b/docutils/test/test_transforms/test_filter_messages.py new file mode 100644 index 000000000..db1250d43 --- /dev/null +++ b/docutils/test/test_transforms/test_filter_messages.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 + +# $Id$ +# :Copyright: © 2021 Günter Milde. +# :Maintainer: docutils-develop@lists.sourceforge.net +# :License: Released under the terms of the `2-Clause BSD license`_, in short: +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. +# This file is offered as-is, without any warranty. +# +# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause + +""" +Tests for docutils.transforms.universal.FilterMessages. +""" + +if __name__ == '__main__': + import __init__ +from test_transforms import DocutilsTestSupport +from docutils.transforms.universal import Messages, FilterMessages +from docutils.transforms.references import Substitutions +from docutils.parsers.rst import Parser + + +def suite(): + parser = Parser() + settings = {'report_level': 5} # filter all system messages + s = DocutilsTestSupport.TransformTestSuite( + parser, suite_settings=settings) + s.generateTests(totest) + return s + +totest = {} + +totest['system_message_sections'] = ((Substitutions, Messages, FilterMessages), [ +["""\ +.. unknown-directive:: block markup is filtered without trace. +""", +"""\ +<document source="test data"> +"""], +["""\ +Invalid *inline markup is restored to text. +""", +"""\ +<document source="test data"> + <paragraph> + Invalid \n\ + * + inline markup is restored to text. +"""], +["""\ +This |unknown substitution| will generate a system message, thanks to +the "Substitutions" transform. The "Messages" transform will +generate a "System Messages" section and the "FilterMessages" transform +will remove it. +""", +"""\ +<document source="test data"> + <paragraph> + This \n\ + |unknown substitution| + will generate a system message, thanks to + the "Substitutions" transform. The "Messages" transform will + generate a "System Messages" section and the "FilterMessages" transform + will remove it. +"""], +]) + + +if __name__ == '__main__': + import unittest + unittest.main(defaultTest='suite') |
