From 3cb710ad9bd6ea9c96b7d7de4a67fe85323ef7a6 Mon Sep 17 00:00:00 2001 From: milde Date: Sun, 17 Mar 2024 23:30:40 +0000 Subject: [PATCH] Move/rename parser test testing only "rst" to the rst parser test dir. The test skript "parsers/test_parser.py" tests only what happens if the "rst" parser is fed `bytes` input (a TypeError). This is OK for "rst", but other parsers don't need to have this restriction. Move to the "test_rst/" sub-directory and rename to "test_misc.py". git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@9578 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- .../test_parsers/{test_parser.py => test_rst/test_misc.py} | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename docutils/test/test_parsers/{test_parser.py => test_rst/test_misc.py} (69%) diff --git a/docutils/test/test_parsers/test_parser.py b/docutils/test/test_parsers/test_rst/test_misc.py similarity index 69% rename from docutils/test/test_parsers/test_parser.py rename to docutils/test/test_parsers/test_rst/test_misc.py index 319c07521..5133d8388 100755 --- a/docutils/test/test_parsers/test_parser.py +++ b/docutils/test/test_parsers/test_rst/test_misc.py @@ -12,9 +12,8 @@ import sys import unittest if __name__ == '__main__': - # prepend the "docutils root" to the Python library path - # so we import the local `docutils` package. - sys.path.insert(0, str(Path(__file__).resolve().parents[2])) + # prepend the local "docutils root" to the Python library path + sys.path.insert(0, Path(__file__).resolve().parents[2].as_posix()) from docutils import parsers, utils, frontend @@ -22,12 +21,13 @@ from docutils import parsers, utils, frontend class RstParserTests(unittest.TestCase): def test_inputrestrictions(self): + # input must be unicode at all times, check for meaningful Exception parser_class = parsers.get_parser_class('rst') parser = parser_class() document = utils.new_document('test data', frontend.get_default_settings(parser)) - # input must be unicode at all times - self.assertRaises(TypeError, parser.parse, b'hol', document) + with self.assertRaises(TypeError): + parser.parse(b'hol', document) if __name__ == '__main__': -- 2.11.4.GIT