summaryrefslogtreecommitdiff
path: root/docutils
diff options
context:
space:
mode:
authormilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2022-11-24 15:08:32 +0000
committermilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2022-11-24 15:08:32 +0000
commitcfe794d355bfa4790419694cdf86945dac0d9ef0 (patch)
tree5279ecf6751e77ae46270374d79c088e1a9a477e /docutils
parent527098bfe46ad8964f95a62c9690ba0a289e8e57 (diff)
downloaddocutils-cfe794d355bfa4790419694cdf86945dac0d9ef0.tar.gz
Skip individual "recommonmark" tests if "recommonmark" is missing.
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
Diffstat (limited to 'docutils')
-rw-r--r--docutils/test/test_parsers/test_recommonmark/__init__.py28
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_block_quotes.py14
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_bullet_lists.py14
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_enumerated_lists.py14
-rwxr-xr-x[-rw-r--r--]docutils/test/test_parsers/test_recommonmark/test_html_blocks.py14
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_inline_markup.py14
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_line_length_limit.py14
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_line_length_limit_default.py14
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_literal_blocks.py14
-rwxr-xr-x[-rw-r--r--]docutils/test/test_parsers/test_recommonmark/test_misc.py13
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_paragraphs.py14
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_section_headers.py15
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_targets.py15
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_transitions.py15
14 files changed, 156 insertions, 56 deletions
diff --git a/docutils/test/test_parsers/test_recommonmark/__init__.py b/docutils/test/test_parsers/test_recommonmark/__init__.py
index 9cb71807f..fab700f50 100644
--- a/docutils/test/test_parsers/test_recommonmark/__init__.py
+++ b/docutils/test/test_parsers/test_recommonmark/__init__.py
@@ -1,21 +1,11 @@
"""Optional tests with 3rd party CommonMark parser"""
-import unittest
-
-from test import DocutilsTestSupport # NoQA: F401 # before importing docutils!
-
-import docutils.parsers
-
-# TODO: test with alternative CommonMark parsers?
-md_parser = 'recommonmark'
-# md_parser = 'pycmark'
-# md_parser = 'myst'
-try:
- import recommonmark
- docutils.parsers.get_parser_class(md_parser)
-except ImportError:
- raise unittest.SkipTest(f'Cannot test "{md_parser}". '
- 'Parser not found.')
-else:
- if md_parser == 'recommonmark' and recommonmark.__version__ < '0.6.0':
- raise unittest.SkipTest('"recommonmark" parser too old, skip tests')
+# TODO: skip complete directory?
+# if <running under unittest test detection> :
+# # cannot rise SkipTest when running with "alltests.py"
+# try:
+# import recommonmark
+# except ImportError:
+# raise unittest.SkipTest('"recommonmark" parser not found')
+# if recommonmark.__version__ < '0.6.0':
+# raise unittest.SkipTest('"recommonmark" parser too old')
diff --git a/docutils/test/test_parsers/test_recommonmark/test_block_quotes.py b/docutils/test/test_parsers/test_recommonmark/test_block_quotes.py
index 43ebf4163..7a34e02f7 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_block_quotes.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_block_quotes.py
@@ -14,15 +14,24 @@ Test for block quotes in CommonMark parsers
Cf. the `CommonMark Specification <https://spec.commonmark.org/>`__
"""
+from pathlib import Path
+import sys
import unittest
-from test import DocutilsTestSupport # NoQA: F401
+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__).parents[3]))
from docutils.frontend import get_default_settings
-from docutils.parsers.recommonmark_wrapper import Parser
from docutils.utils import new_document
+try:
+ from docutils.parsers.recommonmark_wrapper import Parser
+except ImportError:
+ Parser = None
+@unittest.skipIf(Parser is None, 'Optional "recommonmark" module not found.')
class RecommonmarkParserTestCase(unittest.TestCase):
def test_parser(self):
parser = Parser()
@@ -116,5 +125,4 @@ Here is a paragraph.
if __name__ == '__main__':
- import unittest
unittest.main()
diff --git a/docutils/test/test_parsers/test_recommonmark/test_bullet_lists.py b/docutils/test/test_parsers/test_recommonmark/test_bullet_lists.py
index 7b45dfa9d..b39b36773 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_bullet_lists.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_bullet_lists.py
@@ -14,15 +14,24 @@ Test for bullet lists in CommonMark parsers.
Cf. the `CommonMark Specification <https://spec.commonmark.org/>`__
"""
+from pathlib import Path
+import sys
import unittest
-from test import DocutilsTestSupport # NoQA: F401
+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__).parents[3]))
from docutils.frontend import get_default_settings
-from docutils.parsers.recommonmark_wrapper import Parser
+try:
+ from docutils.parsers.recommonmark_wrapper import Parser
+except ImportError:
+ Parser = None
from docutils.utils import new_document
+@unittest.skipIf(Parser is None, 'Optional "recommonmark" module not found.')
class RecommonmarkParserTestCase(unittest.TestCase):
def test_parser(self):
parser = Parser()
@@ -206,5 +215,4 @@ Unicode bullets are not supported by CommonMark.
]
if __name__ == '__main__':
- import unittest
unittest.main()
diff --git a/docutils/test/test_parsers/test_recommonmark/test_enumerated_lists.py b/docutils/test/test_parsers/test_recommonmark/test_enumerated_lists.py
index e0d7b21b8..a5a21c811 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_enumerated_lists.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_enumerated_lists.py
@@ -13,15 +13,24 @@ Test for enumerated lists in CommonMark parsers
Cf. the `CommonMark Specification <https://spec.commonmark.org/>`__
"""
+from pathlib import Path
+import sys
import unittest
-from test import DocutilsTestSupport # NoQA: F401
+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__).parents[3]))
from docutils.frontend import get_default_settings
-from docutils.parsers.recommonmark_wrapper import Parser
from docutils.utils import new_document
+try:
+ from docutils.parsers.recommonmark_wrapper import Parser
+except ImportError:
+ Parser = None
+@unittest.skipIf(Parser is None, 'Optional "recommonmark" module not found.')
class RecommonmarkParserTestCase(unittest.TestCase):
def test_parser(self):
parser = Parser()
@@ -392,5 +401,4 @@ No item content:
if __name__ == '__main__':
- import unittest
unittest.main()
diff --git a/docutils/test/test_parsers/test_recommonmark/test_html_blocks.py b/docutils/test/test_parsers/test_recommonmark/test_html_blocks.py
index c63a8f68b..90ec9c43b 100644..100755
--- a/docutils/test/test_parsers/test_recommonmark/test_html_blocks.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_html_blocks.py
@@ -14,15 +14,24 @@ Tests for HTML blocks in CommonMark parsers
Cf. the `CommonMark Specification <https://spec.commonmark.org/>`__
"""
+from pathlib import Path
+import sys
import unittest
-from test import DocutilsTestSupport # NoQA: F401
+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__).parents[3]))
from docutils.frontend import get_default_settings
-from docutils.parsers.recommonmark_wrapper import Parser
+try:
+ from docutils.parsers.recommonmark_wrapper import Parser
+except ImportError:
+ Parser = None
from docutils.utils import new_document
+@unittest.skipIf(Parser is None, 'Optional "recommonmark" module not found.')
class RecommonmarkParserTestCase(unittest.TestCase):
def test_parser(self):
parser = Parser()
@@ -101,5 +110,4 @@ A paragraph:
if __name__ == '__main__':
- import unittest
unittest.main()
diff --git a/docutils/test/test_parsers/test_recommonmark/test_inline_markup.py b/docutils/test/test_parsers/test_recommonmark/test_inline_markup.py
index a9e018dfd..a8dfd36f6 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_inline_markup.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_inline_markup.py
@@ -13,15 +13,24 @@ Tests for inline markup in CommonMark parsers
Cf. the `CommonMark Specification <https://spec.commonmark.org/>`__
"""
+from pathlib import Path
+import sys
import unittest
-from test import DocutilsTestSupport # NoQA: F401
+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__).parents[3]))
from docutils.frontend import get_default_settings
-from docutils.parsers.recommonmark_wrapper import Parser
+try:
+ from docutils.parsers.recommonmark_wrapper import Parser
+except ImportError:
+ Parser = None
from docutils.utils import new_document
+@unittest.skipIf(Parser is None, 'Optional "recommonmark" module not found.')
class RecommonmarkParserTestCase(unittest.TestCase):
def test_parser(self):
parser = Parser()
@@ -532,5 +541,4 @@ works except for underline.
if __name__ == '__main__':
- import unittest
unittest.main()
diff --git a/docutils/test/test_parsers/test_recommonmark/test_line_length_limit.py b/docutils/test/test_parsers/test_recommonmark/test_line_length_limit.py
index 9ef2acc56..749deb3d0 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_line_length_limit.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_line_length_limit.py
@@ -14,15 +14,24 @@ Tests for inline markup in docutils/parsers/rst/states.py.
Interpreted text tests are in a separate module, test_interpreted.py.
"""
+from pathlib import Path
+import sys
import unittest
-from test import DocutilsTestSupport # NoQA: F401
+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__).parents[3]))
from docutils.frontend import get_default_settings
-from docutils.parsers.recommonmark_wrapper import Parser
+try:
+ from docutils.parsers.recommonmark_wrapper import Parser
+except ImportError:
+ Parser = None
from docutils.utils import new_document
+@unittest.skipIf(Parser is None, 'Optional "recommonmark" module not found.')
class RecommonmarkParserTestCase(unittest.TestCase):
def test_parser(self):
parser = Parser()
@@ -65,5 +74,4 @@ above the limit
if __name__ == '__main__':
- import unittest
unittest.main()
diff --git a/docutils/test/test_parsers/test_recommonmark/test_line_length_limit_default.py b/docutils/test/test_parsers/test_recommonmark/test_line_length_limit_default.py
index 9c833cc8f..5c5c8e0a7 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_line_length_limit_default.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_line_length_limit_default.py
@@ -15,15 +15,24 @@ Tests for inline markup in docutils/parsers/rst/states.py.
Interpreted text tests are in a separate module, test_interpreted.py.
"""
+from pathlib import Path
+import sys
import unittest
-from test import DocutilsTestSupport # NoQA: F401
+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__).parents[3]))
from docutils.frontend import get_default_settings
-from docutils.parsers.recommonmark_wrapper import Parser
+try:
+ from docutils.parsers.recommonmark_wrapper import Parser
+except ImportError:
+ Parser = None
from docutils.utils import new_document
+@unittest.skipIf(Parser is None, 'Optional "recommonmark" module not found.')
class RecommonmarkParserTestCase(unittest.TestCase):
def test_parser(self):
parser = Parser()
@@ -65,5 +74,4 @@ above the limit
if __name__ == '__main__':
- import unittest
unittest.main()
diff --git a/docutils/test/test_parsers/test_recommonmark/test_literal_blocks.py b/docutils/test/test_parsers/test_recommonmark/test_literal_blocks.py
index 7d45159e9..94b28c547 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_literal_blocks.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_literal_blocks.py
@@ -14,15 +14,24 @@ Tests for literal blocks in CommonMark parsers
Cf. the `CommonMark Specification <https://spec.commonmark.org/>`__
"""
+from pathlib import Path
+import sys
import unittest
-from test import DocutilsTestSupport # NoQA: F401
+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__).parents[3]))
from docutils.frontend import get_default_settings
-from docutils.parsers.recommonmark_wrapper import Parser
+try:
+ from docutils.parsers.recommonmark_wrapper import Parser
+except ImportError:
+ Parser = None
from docutils.utils import new_document
+@unittest.skipIf(Parser is None, 'Optional "recommonmark" module not found.')
class RecommonmarkParserTestCase(unittest.TestCase):
def test_parser(self):
parser = Parser()
@@ -217,5 +226,4 @@ with class ``eval_rst``.
if __name__ == '__main__':
- import unittest
unittest.main()
diff --git a/docutils/test/test_parsers/test_recommonmark/test_misc.py b/docutils/test/test_parsers/test_recommonmark/test_misc.py
index 442c4b2d4..7e52d0747 100644..100755
--- a/docutils/test/test_parsers/test_recommonmark/test_misc.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_misc.py
@@ -13,11 +13,21 @@
Various tests for the recommonmark parser.
"""
+from pathlib import Path
+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__).parents[3]))
+
from docutils.core import publish_string
from docutils.parsers.rst import directives as rst_directives
-from docutils.parsers.recommonmark_wrapper import Parser
+try:
+ from docutils.parsers.recommonmark_wrapper import Parser
+except ImportError:
+ Parser = None
sample_with_html = """\
@@ -34,6 +44,7 @@ Final paragraph.
"""
+@unittest.skipIf(Parser is None, 'Optional "recommonmark" module not found.')
class RecommonmarkParserTests(unittest.TestCase):
def test_parser_name(self):
diff --git a/docutils/test/test_parsers/test_recommonmark/test_paragraphs.py b/docutils/test/test_parsers/test_recommonmark/test_paragraphs.py
index dfe1d9c03..08ec3aae5 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_paragraphs.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_paragraphs.py
@@ -8,15 +8,24 @@
Tests for states.py.
"""
+from pathlib import Path
+import sys
import unittest
-from test import DocutilsTestSupport # NoQA: F401
+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__).parents[3]))
from docutils.frontend import get_default_settings
-from docutils.parsers.recommonmark_wrapper import Parser
+try:
+ from docutils.parsers.recommonmark_wrapper import Parser
+except ImportError:
+ Parser = None
from docutils.utils import new_document
+@unittest.skipIf(Parser is None, 'Optional "recommonmark" module not found.')
class RecommonmarkParserTestCase(unittest.TestCase):
def test_parser(self):
parser = Parser()
@@ -88,5 +97,4 @@ Line 3.
]
if __name__ == '__main__':
- import unittest
unittest.main()
diff --git a/docutils/test/test_parsers/test_recommonmark/test_section_headers.py b/docutils/test/test_parsers/test_recommonmark/test_section_headers.py
index ca4d39b6f..4970c814e 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_section_headers.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_section_headers.py
@@ -13,15 +13,25 @@ Test for section headings in CommonMark parsers.
Cf. the `CommonMark Specification <https://spec.commonmark.org/>`__
"""
+from pathlib import Path
+import sys
import unittest
-from test import DocutilsTestSupport # NoQA: F401
+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__).parents[3]))
+
from docutils.frontend import get_default_settings
-from docutils.parsers.recommonmark_wrapper import Parser
+try:
+ from docutils.parsers.recommonmark_wrapper import Parser
+except ImportError:
+ Parser = None
from docutils.utils import new_document
+@unittest.skipIf(Parser is None, 'Optional "recommonmark" module not found.')
class RecommonmarkParserTestCase(unittest.TestCase):
def test_parser(self):
parser = Parser()
@@ -249,5 +259,4 @@ Empty Section
if __name__ == '__main__':
- import unittest
unittest.main()
diff --git a/docutils/test/test_parsers/test_recommonmark/test_targets.py b/docutils/test/test_parsers/test_recommonmark/test_targets.py
index 09306db34..cee0d6898 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_targets.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_targets.py
@@ -13,15 +13,25 @@ Test for targets in CommonMark parsers.
Cf. the `CommonMark Specification <https://spec.commonmark.org/>`__
"""
+from pathlib import Path
+import sys
import unittest
-from test import DocutilsTestSupport # NoQA: F401
+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__).parents[3]))
+
from docutils.frontend import get_default_settings
-from docutils.parsers.recommonmark_wrapper import Parser
+try:
+ from docutils.parsers.recommonmark_wrapper import Parser
+except ImportError:
+ Parser = None
from docutils.utils import new_document
+@unittest.skipIf(Parser is None, 'Optional "recommonmark" module not found.')
class RecommonmarkParserTestCase(unittest.TestCase):
def test_parser(self):
parser = Parser()
@@ -152,5 +162,4 @@ Paragraph with link to [title].
if __name__ == '__main__':
- import unittest
unittest.main()
diff --git a/docutils/test/test_parsers/test_recommonmark/test_transitions.py b/docutils/test/test_parsers/test_recommonmark/test_transitions.py
index 25621bf7a..e87fa6b9d 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_transitions.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_transitions.py
@@ -8,15 +8,25 @@
Tests for transitions (`thematic breaks`).
"""
+from pathlib import Path
+import sys
import unittest
-from test import DocutilsTestSupport # NoQA: F401
+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__).parents[3]))
+
from docutils.frontend import get_default_settings
-from docutils.parsers.recommonmark_wrapper import Parser
+try:
+ from docutils.parsers.recommonmark_wrapper import Parser
+except ImportError:
+ Parser = None
from docutils.utils import new_document
+@unittest.skipIf(Parser is None, 'Optional "recommonmark" module not found.')
class RecommonmarkParserTestCase(unittest.TestCase):
def test_parser(self):
parser = Parser()
@@ -325,5 +335,4 @@ A paragraph.
if __name__ == '__main__':
- import unittest
unittest.main()