summaryrefslogtreecommitdiff
path: root/docutils/test/test_transforms
Commit message (Collapse)AuthorAgeFilesLines
* Fix test failure introduced in [r9348].milde2023-04-171-4/+24
| | | | | | | | | Reword and wrap warning message for incompatible content of the bibliographic field "author". Adapt "frontmatter" unit test cases. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9351 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix message for nonconforming docinfo-Authors.grubert2023-04-161-4/+4
| | | | git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9350 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix test for spurious enumerated lists in bibliographic fields.milde2023-04-141-0/+3
| | | | | | | The test for "single line paragraphs" failed for bibliographic fields followed by an empty line. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9348 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* More user-friendly DocInfo transform.milde2023-01-171-4/+8
| | | | | | | | | | | | | More detailled feedback when extracting data from a bibliographic field fails. In bibliographic fields expecting a single paragraph (e.g. "author"), restore enumerated lists originating in ambiguous markup like "A. Einstein" (name with initial): in the given context, an we know that this should not be an enumeration, so fixing is better than throwing an error. Fix some cases of "ersatz" Boolean values from pre Python 2.3 times. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9322 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix failures when running "transform" test modules as "__main__".milde2023-01-172-40/+33
| | | | | | | | | | | | | | | | | | | | | | | Also restructure `test_docinfo` to reduce code duplication. Running "transform" test modules independently failed due to an additional INFO message: Loading a language module results in an INFO message. Import statements don't trigger the INFO message if the language module is already loaded. When running a test module as __main__, the INFO message is added to the first document using both, the language module and the `Messages` or `TestMessages` transform. When running the test suite, the language module may already be loaded by another test. For stable results, the optional message must be filtered. In "transform" tests, we do not load the default transforms, so INFO messages are only filtered if `FilterMessages` is explicitly added. As `FilterMessages` only acts on attached messages, it must run *after* `TestMessages`, therefore we load it with custom priority 890. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9321 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix IndexError when running individual test modules under Python <3.9milde2022-11-2622-22/+22
| | | | | | | | | Up to Python 3.8, __file__ returns a relative path for the main script specified on the command line. Use `Path.resolve()` to make it absolute before calling `Path.parents`. https://docs.python.org/3/whatsnew/3.9.html#other-language-changes git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9277 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix import errors with ``python -m unittest``.milde2022-11-2521-20/+127
| | | | | | | | Running standard unittest on the test suite resulted in 89 ImportErrors because ``import DocutilsTestSupport was used to set up sys.path() but the module could not be found on the original sys.path(). git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9274 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Remove spurious "import unittest" from test scripts.milde2022-11-2421-21/+0
| | | | | | | There was a "late" import if __name__ == "__main__" which is no longer required when importing `unittest` at the top. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9269 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Reset not only `_roles` but also `_directives` cache dictionary.milde2022-11-241-3/+9
| | | | | | | | | | | | | | | | Clean the global caches to ensure predictable test results. (There were additional warnings for undefined directive and role names under Windows. These were suppressed due to other tests adding canonical names to the cache under Linux.) Add additional warnings to the expected output samples. Registering directives at test module level no longer works. Move `register_directive()` call to the test function. Signed-off-by: milde <milde@users.sf.net> git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9265 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Add support for ``pytest``aa-turner2022-11-101-0/+3
| | | | | | | | | | | | This is the minimal configuration required for the test suite to pass using the pytest framework. This is part of the test suite refactoring project. - Ignore two classes that start with the word "Test" - Provide the standard test header to pytest - Update the documentation git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9237 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Inline ``TransformTestSuite``aa-turner2022-11-0922-268/+697
| | | | | | | | | - Move all usages of ``TransformTestSuite.generateTests`` to using subtests, as part of the test suite refactoring project - Fix the global state issues with ``test_hyperlinks_de`` and run the test as part of ``alltests.py`` git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9229 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix newline problems, further simplify ``compare_output``aa-turner2022-10-212-2/+2
| | | | git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9169 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Remove all ``import __init__`` statements, as part of theaa-turner2022-10-2121-42/+0
| | | | | | | unittest migration. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9141 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Import ``DocutilsTestSupport`` from ``test``aa-turner2022-10-2122-35/+21
| | | | | | | | | | | | This is the first step of moving to the standard ``unittest`` style. It involves making the ``test/`` directory a psuedo-package and importing the ``DocutilsTestSupport`` module from it, instead of the path manipulation previously carried out in ``__init__.py`` files. As of this, we also blank out all ``__init__.py`` files in the test directories. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9140 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Remove unused imports.milde2022-03-0523-32/+29
| | | | | | flake8 rule F401 git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9037 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Ensure 2 blank lines around top-level functions and classes.milde2022-03-0418-0/+22
| | | | | | | | flake8 rules E302: expected 2 blank lines, found 1 E305: expected 2 blank lines after class or function definition git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9026 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Remove excess blank lines.milde2022-03-041-1/+0
| | | | | | flakei rule E303: too many blank lines (N) git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9025 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Ensure at least two spaces before inline comment.milde2022-03-046-7/+7
| | | | | | | | | flake 8 rule E261 Exceptions for modules sheduled for removal or with 3rd-party origin and for data collections. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9021 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix missing whitespace after ',' or ':'.milde2022-03-031-2/+4
| | | | | | | | flake8 rule E231. Mostly trailing commas in list and dictionary literals. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9018 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix whitespace before/after delimiters and colon.milde2022-03-031-1/+1
| | | | | | | | | | | | | | Flake rules E201 whitespace after '(' E202 whitespace before '}' E203 whitespace before ':' E211 whitespace before '(' Exception: : as binary operator in extended slices (cf. https://www.python.org/dev/peps/pep-0008/#pet-peeves). git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9015 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix FilterMessages transform [bug:#435].milde2022-02-031-0/+75
| | | | | | | | | | | 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
* Fix trailing whitespace (flake warnings W293, W391).milde2022-01-293-6/+6
| | | | | | | W293 blank line contains whitespace W391 blank line at end of file git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8993 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix trailing whitespace (flake warning W291).milde2022-01-294-12/+12
| | | | git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8992 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Drop string prefix "u".milde2022-01-265-35/+35
| | | | git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8983 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix/silence DeprecationWarnings and RessourceWarnings.milde2022-01-061-28/+0
| | | | | | | Found by Tomasz Kłoczko running "pytest" (cf. feature-request #81) and by running `python3 -W all alltests.py`. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8933 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Drop special-casing for Python 2.x in tests and tools.milde2022-01-031-1/+1
| | | | | | | Use "python3" in the shebang line (cf. PEP 394 -- The "python" Command on Unix-Like Systems). git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8927 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Remove "coding:" slugmilde2022-01-032-5/+1
| | | | | | Only required with Python 2.x. Encoding in Py3k is utf8 by default. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8926 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Remove 2.7-compatibility __future__ imports.milde2022-01-0321-44/+21
| | | | git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8925 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Skip system_messages when propagating targets. Fixes bug #425.milde2021-09-202-5/+80
| | | | | | | Testing with "alltests.py" is currently impossible due to caching (see itest_hyperlinks_de.py) git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8831 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Reorganise functional tests.milde2021-06-301-0/+18
| | | | | | | | | | | Move additional tests for special features or problems specific to the output format from the "standalone_..." generic test case to additional tests. Use unit test instead of functional test for the fix in r6155 (hyperlink references in substitutions). git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8784 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Change default value for the "auto_id_prefix" setting to "%".milde2021-06-1810-204/+204
| | | | | | | Auto-generated IDs use the tag name as prefix. Set auto_id_prefix_ to "id" if you want unchanged auto-IDs. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8771 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Limit length of input lines and substitution expansion.milde2020-09-141-0/+71
| | | | | | | | | | | | | | | | | | Mitigate the danger of DoS attacs using specially crafted rST input (cf. bug #381). The default value of 10 000 characters should suffice for legitimate use cases (e.g. long paragraphs in auto-wrapping editors or extensive creative use of substitutions). Applications processing untrusted rST might wish to lower this limitation (together with other safety measures described in docs/howto/security.txt). Unsupervised processing of untrusted rST input should always be safeguarded with limits on processing time and memory use. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8565 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix link to 2-Clause BSD license.milde2020-09-041-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8554 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Restore support for running tests stand-alone.milde2020-01-3119-19/+55
| | | | | | | | | After the switch to absolute imports, individual test could no longer be run in from their directory (import error). This patch makes the `pythonpath` expansion in the test subdirectories' ``__init__`` files functional again. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8481 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix [ 383 ] Smart quotes around opening and separator characters.milde2020-01-261-13/+32
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8469 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Do not rely on `nodes.Node.traverse()` returning a "list" instance.milde2019-09-061-0/+2
| | | | | | | While the current implementation actually returns a list of nodes, the docstring specifies only: "Return an iterable ...". git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8387 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Add test for "strip-classes" setting.milde2019-09-061-5/+5
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8385 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* py3: Use 'absolute_import' futuremilde2019-08-2619-22/+44
| | | | | | | | This mostly applies to tests. Signed-off-by: Stephen Finucane <stephen@that.guru> git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8356 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* py3: Switch to print functionsmilde2019-08-262-6/+6
| | | | | | | | | | Remove all uses of print as a statement. This includes comments, many of which are simply removed as noise (they're in version control and can be re-added later, if necessary). Signed-off-by: Stephen Finucane <stephen@that.guru> git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8346 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix py38 SyntaxWarning: invalid escape sequence \grubert2019-08-119-90/+90
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8311 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix #332 and #342 (smartquotes problems).milde2019-07-241-9/+116
| | | | | | | Standard backslash escape for smartquotes. No escape in roles descending from `inline literal`. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8301 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Unescape null-escaped content in nodes.Text.astext().milde2019-07-221-43/+43
| | | | | | | | | | | Store the null-escaped text in the doctree nodes and unescape in nodes.Text.astext(). Enables functions and transforms processing Text nodes to respect backslash escapes. Provides backslash-escaping of the `author separator` in the "authors" docinfo field and the `classifier delimiter` in definition list terms. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8284 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Revert the fix for backslash escaping in transforms.milde2018-11-211-109/+8
| | | | | | | | | Still waiting for review. Reverts last three commits from a local "feature branch" unintentionally applied to trunk with `git svn`. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8235 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* smartquotes: Use single backslashes for escaping.milde2018-11-201-8/+109
| | | | | | | | Let the smartquote transform take advantage of the representation of escaping backslashes in the doctree as null characters. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8234 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* DocInfo transform must not use "rawsource" attribute for escaping.milde2018-11-201-48/+48
| | | | | | | | | | | Remove implementation of escaping author-separators in bibliographic fields that relies on the "rawsource" attribute. This is not safe (rawsource is only for information and debugging purposes). A proper fix can be done with null-escaped text in the doctree. C.f. https://sourceforge.net/p/docutils/bugs/_discuss/thread/c8f86be6/74ed/attachment/null-escape-in-doctree2.patch git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8231 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix a typo.milde2018-01-141-10/+10
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8210 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Add <target> to one more testcase (see r8206).milde2017-12-191-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8207 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Add tagname to "illegal element" substitution definition error message.milde2017-12-181-1/+1
| | | | | | | Be a bit more verbose when detecting nodes that are disallowed inside substitution definitions. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8206 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Ignore backslash-escaped separators when extracting authors from a paragraph.milde2017-11-041-0/+43
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8198 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* smartquotes: Fix bug #332.milde2017-10-251-6/+36
| | | | | | | | Use open quote after whitespace, ZWSP, and ZWNJ. Code cleanup. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8190 929543f6-e4f2-0310-98a6-ba3bd3dd1d04