summaryrefslogtreecommitdiff
path: root/docutils/test/test_io.py
Commit message (Collapse)AuthorAgeFilesLines
* Revert addition of `io.OutString` and the "auto_encode" argument.milde2023-05-021-59/+0
| | | | | | | 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
* Add "auto_encode" argument to `publish_string()`milde2023-04-061-0/+59
| | | | | | | | | | | | | | | | Add "auto_encode" argument to publish_string() and publish_programmatically() to give the user an option to select the output type (`bytes` or `OutString`) in a way that does not interfere with the intended encoding of the output (the problem with the "dummy" output encoding name ``unicode``). The default will change from ``False`` to ``True`` in Docutils 0.22 New class for `io.StringOutput`: `io.OutString` adds "encoding" and "errors" attributes to `str`. Allows storing the "output_encoding" and "output_encoding_error_handler" settings in a transparent and easy to process way. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9336 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Avoid ambiguous module name `io`.milde2023-02-071-49/+50
| | | | | | | There are standard `io` and `docutils.io`. Avoid ambiguity by not using ``from docutils import io``. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9329 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Allow empty string as encoding value (to re-activate default).milde2022-12-021-1/+3
| | | | | | | | | Value `None` cannot be specified on the command line. Use ``--input-encoding=""`` go back to Docutil's default behaviur (use encoding indicated in the file or fallbacks) if a config file sets "input_encoding" to another value. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9303 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix IndexError when running individual test modules under Python <3.9milde2022-11-261-1/+1
| | | | | | | | | 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-251-0/+6
| | | | | | | | 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
* Make the tests agnostic to the working directoryaa-turner2022-11-101-7/+18
| | | | | | | | | | | 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
* Update test after the fix in [r9098].milde2022-07-101-4/+0
| | | | | | | | Remove exception for Py3k input encoding handling in 0.18. Input detection is now always used if the `input_encoding` setting is not specified. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9110 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Detail planned input-encoding changes.milde2022-07-081-6/+5
| | | | git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9109 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Test decoding result instead of "successful_encoding" variable value.milde2022-07-061-6/+6
| | | | | | | In future, the removal of BOM marks will be handled by the codec, leading to different "successful_encoding" values but the same result. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9108 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Test input file encoding auto-detection.milde2022-07-041-0/+47
| | | | | | | | | | Currently, one test fails due to invalid utf-16. Four tests fail if the locale encoding is a legacy 8-bit encoding due to character mix-up (mojibake) despite a correct encoding declaration in the file. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9097 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
* Documentation updatemilde2022-06-171-2/+2
| | | | | | | | | | | | Remove dead link and outdated footnote about limitations in Python2. Add link to acceptable values of encoding error handlers. Harmonise help output. Use UTF-8 in prose text, error messages, and documentation. Use 'utf-8' in code or when referring to code. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9077 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-8/+9
| | | | git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9068 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Remove unused local variablesmilde2022-03-051-5/+4
| | | | | | | | 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-051-1/+0
| | | | | | flake8 rule F401 git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9037 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Remove excess blank lines.milde2022-03-041-2/+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-041-5/+6
| | | | | | | | | 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 around operator.milde2022-03-031-1/+1
| | | | | | | | | | | | | | flake8 rules E225: missing whitespace around operator E226: missing whitespace around arithmetic operator E228: missing whitespace around modulo operator Keep ignoring the latter two rules: PEP8 limits the recommendation to "operators with lowest priority" "if operators with different priorities are used". flake8 also flags top level operators. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@9017 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Simplify/modernise tests for exceptions and warnings.milde2022-02-211-5/+2
| | | | | | | | | | 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
* Fix code indentationmilde2022-01-291-4/+4
| | | | | | | | | | | | | | | | | | | | Check conformance to our coding policies with flake8. Fix the following problems: E111 indentation is not a multiple of four E114 indentation is not a multiple of four (comment) E115 expected an indented block (comment) E116 unexpected indentation (comment) E117 over-indented E121 continuation line under-indented for hanging indent E122 continuation line missing indentation or outdented E124 closing bracked does not match visual indentaion E127 continuation line over-indented for visual indent E128 continuation line under-indented for visual indent E131 continuation line unaligned for hanging indent git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8994 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix trailing whitespace (flake warnings W293, W391).milde2022-01-291-2/+2
| | | | | | | 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
* Various small fixes.milde2022-01-291-1/+1
| | | | | | | | | | | | Update comments One more generator expression instead of lists. Fix unbound variable. Drop duplicate import. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8990 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Drop string prefix "u".milde2022-01-261-18/+18
| | | | git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8983 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Remove redundant parenthesesmilde2022-01-261-1/+1
| | | | | | Patch by Adam Turner. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8976 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Small fixes and clean-ups by Adam Turner.milde2022-01-261-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Remove duplicate definitions in language modules. Import locale_encoding from `docutils.io` Use decorator for staticmethod Use True/False over 1/0. `collections.OrderedDict` no longer required, all dictionaries are ordered from Python 3.7 Remove obsolete `__cmp__` method cf. https://docs.python.org/3/whatsnew/3.0.html#ordering-comparisons Use str instead of type(''). Zero-argument ``super()`` Simplify test support module as "u" prefix isn't used by repr in Python 3. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8973 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Drop use of utils.error_reporting module and deprecate it.milde2022-01-071-3/+74
| | | | | | | | | | SafeString not required in Python 3 ErrorString obsoleted by new function io.error_string(). ErrorOutput and locale_encoding moved to docutils.io. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8937 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Drop special-casing for Python 2.x in tests and tools.milde2022-01-031-43/+26
| | | | | | | 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
* Add DeprecationWarnings and FutureWarnings for planned changes.milde2021-11-051-1/+11
| | | | git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8880 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Deprecation warning updates.milde2021-11-051-18/+0
| | | | | | | | | | - Make `frontend.ConfigDeprecationWarning` a subclass of `FutureWarning` as it is also intended for end users. https://docs.python.org/3/library/warnings.html#warning-categories - Update deprecation warning tests. git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8879 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Formatting changes to facilitate integration of "py3" patchset.milde2019-08-271-4/+4
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8367 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* py3: Switch to print functionsmilde2019-08-261-2/+2
| | | | | | | | | | 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
* comment test_deprecation_warning grubert2019-07-221-0/+3
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8283 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Apply patch #157: In test/test_io.py method test_deprecation_warning ...grubert2019-07-221-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8282 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix [ 348 ] Since Python 3.4, the 'U' universal newlines mode has been ↵grubert2018-09-091-0/+15
| | | | | | deprecated (thanks to hugovk). git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8228 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Drop 2.4 and 2.5 compatibility code, part 2.milde2017-08-141-10/+9
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8164 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Drop compatibility code for Python 2.4 and 2.5.milde2017-08-111-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8163 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix [ 318 ] false positive in test_heuristics_no_utf8.milde2017-05-311-3/+10
| | | | | | | The heuristics is skipped under Py3k unless decoding with locale encoding fails. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8098 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix test under Py3k.milde2013-03-041-2/+2
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7622 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Test case for io.Input.decode with "unicode" data. Cf. bug [ 3606659 ].milde2013-03-041-1/+9
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7620 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix Py3k error writing to stdout with encoding differing from default.milde2012-10-111-14/+16
| | | | | | Cleanup of the workarounds for Py3k encoding problems. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7525 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* math, error_reporting, and urischemes moved to the utils package. milde2012-06-251-1/+1
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7464 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Drop support for Python 2.3.milde2012-06-221-4/+0
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7463 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fixup: more save implementation of binary data output under Python 3.milde2012-06-131-6/+100
| | | | | | Prevent test error under Python 3. Add tests for FileOutput. Document. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7440 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* python 2.3 alias unittest.TestCase.assertTrue (possibly reverted on next ↵grubert2012-05-011-0/+4
| | | | | | release) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7400 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Fix false positive with non-UTF8, non-latin1 locale encodings.milde2011-12-061-4/+9
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7248 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* Tests for encoding problemsmilde2011-11-081-8/+27
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7217 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* New sub-module and test suite for error reporting.milde2011-05-191-153/+0
| | | | | | | | * Code to handle encoding/decoding errors when reporting exceptions. * Test and fix error reporting with problematic locale settings. (https://bugs.gentoo.org/show_bug.cgi?id=349101) git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7037 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
* in Python 3, the name for the exception instance is local to the except clausemilde2011-05-161-8/+8
| | | | git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7036 929543f6-e4f2-0310-98a6-ba3bd3dd1d04