summaryrefslogtreecommitdiff
path: root/docutils/test/test_parsers
Commit message (Collapse)AuthorAgeFilesLines
* Revert addition of `io.OutString` and the "auto_encode" argument.milde2023-05-022-21/+17
| | | | | | | We need a review of the "string output" interface and a consensus on the "clean" end-state before starting with the implementation. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9369 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Test syntax highlight: Make pygments version parsing more robust.milde2023-04-173-21/+10
| | | | | | | Do not fail for pre-release versions (c.f. https://pygments.org/docs/changelog/). git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9355 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Support Pygments 2.14 and newer in testsmilde2023-04-173-0/+278
| | | | | | | | | Pygments 2.14 contains changes in the Python lexer which break ``test_code``​​, ``test_code_long``, and ``test_include``. https://pygments.org/docs/changelog/#version-2-14-0 git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9354 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix regex to match multiline message "requires ... recommonmark"grubert2023-04-131-1/+2
| | | | git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9346 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Set "auto_encode=False" to skip en-/decoding output in tests.milde2023-04-112-10/+11
| | | | git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9341 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Update test documentation. Set executable bit on test scripts.milde2022-12-132-0/+0
| | | | | | | | | | | Don't mention the "nose" test framework. (It is unmaintained, deprecated, and fails to find all test cases.) Hint to a possible future dependency on "pytest". Two recently added test scripts missed the executable bit. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9308 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Simplify error message if recommonmark is missing.milde2022-12-021-1/+1
| | | | | | | | | As we provide a mock Sphinx package, there is no need to emphasise recommonmark's dependency on Sphinx. Wrap error message. Adapt the test case. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9302 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Skip test_recommonmark/ directory if recommonmark is missing.milde2022-12-0214-74/+18
| | | | | | | | | | | After basing "alltests.py" on the `unittest.defaultTestLoader`, we can (again) skip the complete directory from the __init__.py file. Simplify recommonmark test files (when running individually, failing with an ImportError when recommonmark is missing is no problem). Keep the `sys.path` setup, we still want test the local "docutils" package. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9301 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix IndexError when running individual test modules under Python <3.9milde2022-11-2681-82/+82
| | | | | | | | | 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-2564-73/+388
| | | | | | | | 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-2463-63/+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
* Fix failure when "pygments" is not installed.milde2022-11-241-5/+10
| | | | | | | | | A name mismatch occured during the test refactoring which prevented deleting a test sample requiring "pygments". Signed-off-by: milde <milde@users.sf.net> git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9266 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Reset not only `_roles` but also `_directives` cache dictionary.milde2022-11-242-5/+43
| | | | | | | | | | | | | | | | 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
* Skip individual "recommonmark" tests if "recommonmark" is missing.milde2022-11-2414-56/+156
| | | | | | | | Skipping the complete test directory does not work with "alltests.py". Also fix running the individual tests scripts. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9264 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix running of individual test (first batch).milde2022-11-2410-7/+23
| | | | | | | | | | | | | | | | | | After test refactoring, test scripts failed with ImportError unless started from the "test root" ``docutils/test/``. Prepend the "docutils root" to the Python library path so we import the local `docutils` and `test` packages, ignoring an eventually installed Docutils package. Set executable bit where this was missing. Also: Use "pathlib" instead of "os.path" for self-documenting path manipulations. Remove duplicate ``import unittest`` statements. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9263 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Make the tests agnostic to the working directoryaa-turner2022-11-106-54/+77
| | | | | | | | | | | Previously, the test suite only worked when the current working directory was ``docutils/test/`. With this change all relative paths are calculated explicitly such that the working directory no longer affects the tests, meaning a less fragile test environment and greater flexibility to use test runners other than ``alltests.py``. This is part of the test suite refactoring project. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9236 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Make ``test_include`` independent of the CWDaa-turner2022-11-091-267/+268
| | | | | | | | | Tests in ``test_include`` previously only passed when the current working directory was equal to the test root. This change makes it possible to run the tests without changing the CWD, as part of the test suite refactoring project git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9233 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Inline ``exception_data``aa-turner2022-11-095-21/+68
| | | | | | | - Move all usages of ``exception_data`` to using the ``try`` / ``except`` pattern as part of the test suite refactoring project git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9232 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Inline ``ParserTestSuite``aa-turner2022-11-0961-389/+1262
| | | | | | | - Move all usages of ``ParserTestSuite.generateTests`` to using subtests, as part of the test suite refactoring project git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9230 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Inline ``TransformTestSuite``aa-turner2022-11-091-11/+27
| | | | | | | | | - 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
* Inline ``GridTableParserTestSuite``aa-turner2022-11-081-6/+35
| | | | | | | - Move all usages of ``GridTableParserTestSuite.generateTests`` to using subtests, as part of the test suite refactoring project git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9224 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Inline ``SimpleTableParserTestSuite``aa-turner2022-11-081-6/+19
| | | | | | | - Move all usages of ``SimpleTableParserTestSuite.generateTests`` to using subtests, as part of the test suite refactoring project git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9223 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Inline ``RecommonmarkParserTestSuite``aa-turner2022-11-0815-98/+274
| | | | | | | | | | | - Move all usages of ``RecommonmarkParserTestSuite.generateTests`` to using subtests. - Move the conditional test skipping logic to ``__init__.py`` in ``test_recommonmark``, and move the missing module test from ``test_recommonmark.test_misc`` to ``test_get_parser_class``, as otherwise the test would never run. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9222 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Simplify and expand tests for handling the encoding of included files.milde2022-11-073-26/+114
| | | | | | | | | Use a simpler sample file for signed UTF-16 input. Test encoding auto-detection to ensure it is in sync with encoding handling for the main document. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9220 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Partially revert r9167aa-turner2022-11-022-7/+13
| | | | | | | | | | | | | | | | | | | | ``docutils.core.publish_string`` uses Python 2 notion of a bytestring, such that in the general case it returns Python 3's ``bytes`` type. Revision 9167 attempted to address this distinction by introducing ``publish_bytes`` and changing ``publish_string`` to always return unicode text data as Python's ``str`` type. This is a backwards compatibility break, so in this commit we restore the previous behaviour, whilst simultaneously deprecating support for returning binary data from the ``docutils.core.publish_string`` function for at least two releases of Docutils. As part of this, we also deprecate returning binary data from the ``docutils.io.StringOutput.encode`` method, docutils.io.BytesOutput`` should be used in its stead. Finally, we update tests for the reversion to the previous behaviour. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9202 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Normalise all test section namesaa-turner2022-10-2814-25/+25
| | | | | | | Ensure all names are lowercase, and replace all non-alpha characters with underscores. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9193 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix newline problems, further simplify ``compare_output``aa-turner2022-10-216-7/+13
| | | | git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9169 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Simplify ``CustomTestCase.compare_output``aa-turner2022-10-212-13/+13
| | | | | | | | Ensure that the ``core.publish_string`` always returns a string, introduce ``core.publish_bytes`` for binary output. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9167 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Use ``docutils.utils`` over ``DocutilsTestSupport.utils``aa-turner2022-10-213-6/+10
| | | | git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9164 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Subclass directly from ``unittest.TestCase``aa-turner2022-10-212-6/+4
| | | | git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9148 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Remove all ``import __init__`` statements, as part of theaa-turner2022-10-2178-156/+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-2182-134/+78
| | | | | | | | | | | | 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
* Resolve flake8 ``E275`` erroraa-turner2022-10-203-4/+4
| | | | | | | E275: missing whitespace after keyword git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9127 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Code style fixes.milde2022-09-132-2/+3
| | | | git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9122 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Rename `io.locale_encoding` to mark it as internal.milde2022-06-171-2/+2
| | | | | | | | | | The attribute was moved to "io" after the last release. Backwards compatibility is ensured via `locale_encoding` in the (deprecated) "utils.error_reporting" module. Fix HISTORY entries. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9078 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Ensure locale_encoding is lower case.milde2022-06-151-1/+1
| | | | | | | Use `locale.getpreferredencoding(False)` since we dropped support for older Python versions with side-effects. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9074 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Unify naming of the "utf-8" codec.milde2022-06-131-3/+4
| | | | git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9068 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* New wrapper module for "CommonMark" parsers.milde2022-03-291-9/+9
| | | | | | | | | | | | | | | | | | The parser names 'commonmark' and 'markdown' now select the first locally installed parser from a list of compatible 3rd-party parser packages (pycmark, myst, and recommonmark). The parsers return slightly different doctrees. This should not matter for HTML output but leads to false negatives with the "include" directive test. Therefore the test case now specifies "recommonmark". The "pycmark" parser defines transformations to comlete nested parsing and clean up non-standard nodes. These transformations must also be run when including a document fragment. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9048 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Prepare switch from optparse to argparse.milde2022-03-171-2/+2
| | | | | | | | | | | | | New interface function: frontend.get_default_settings() easy access to default settings for programmatic use. Add deprecation warnings. Catch them when accessing the deprecated functions from Docutils. Make docstrings conform to the Documentation Policies (first line: summary, next line empty). git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9047 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Update PEP base URL and template.milde2022-03-131-1/+1
| | | | | | | | | | | | | | The canonical PEP base URL changed to "peps.python.org/". The PEP-writer template.txt added a "source" link that no longer works due to sources now only be stored on github and having two possible file extensions ("txt" or "rst"). Adapt the header to resemble the header of official PEP documents (which are now produced using Sphinx). Fixes [bug:#445]. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9045 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Remove unused local variablesmilde2022-03-051-2/+3
| | | | | | | | flake rule F841: local variable 'foo' is assigned to but never used In test_odt.py, a no-op class definition is removed completely. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9038 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Remove unused imports.milde2022-03-0585-98/+85
| | | | | | flake8 rule F401 git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9037 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix invalid escape sequences.milde2022-03-051-6/+4
| | | | | | flake 8 rule W605 git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9036 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Do not use bare 'except'.milde2022-03-051-1/+1
| | | | | | | | | | flake8 rule E722 Exception: as catchall, if * the right thing to do does not depend on the error * any error is reported or risen again. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9033 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Ensure 2 blank lines around top-level functions and classes.milde2022-03-0479-0/+108
| | | | | | | | 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-047-9/+9
| | | | | | | | | 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-034-4/+7
| | | | | | | | 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-3/+3
| | | | | | | | | | | | | | 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
* Simplify/modernise tests for exceptions and warnings.milde2022-02-212-9/+6
| | | | | | | | | | Use unicode.assertWarnsRegex() instead of "hand written" warnings catching. Use unicode.assertRaises() as context manager (unless this would mean an additional code line). git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9011 929543f6-e4f2-0310-98a6-ba3bd3dd1d04