summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2022-12-02 17:13:54 +0000
committermilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2022-12-02 17:13:54 +0000
commitea7648566091d977de9aa850d1c7ff1c18786d06 (patch)
tree46072ac13a6df9d27a29a7d6ad05ef7348cdac3f
parentbf090dd8f51779456353565f80cf1d72597874be (diff)
downloaddocutils-ea7648566091d977de9aa850d1c7ff1c18786d06.tar.gz
Skip test_recommonmark/ directory if recommonmark is missing.
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
-rw-r--r--docutils/test/test_parsers/test_recommonmark/__init__.py14
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_block_quotes.py6
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_bullet_lists.py6
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_enumerated_lists.py6
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_html_blocks.py6
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_inline_markup.py6
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_line_length_limit.py6
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_line_length_limit_default.py6
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_literal_blocks.py6
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_misc.py5
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_paragraphs.py6
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_section_headers.py6
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_targets.py6
-rwxr-xr-xdocutils/test/test_parsers/test_recommonmark/test_transitions.py7
14 files changed, 18 insertions, 74 deletions
diff --git a/docutils/test/test_parsers/test_recommonmark/__init__.py b/docutils/test/test_parsers/test_recommonmark/__init__.py
index fab700f50..7dc6fa9e3 100644
--- a/docutils/test/test_parsers/test_recommonmark/__init__.py
+++ b/docutils/test/test_parsers/test_recommonmark/__init__.py
@@ -1,11 +1,7 @@
"""Optional tests with 3rd party CommonMark parser"""
-# 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')
+import unittest
+try:
+ import docutils.parsers.recommonmark_wrapper # noqa: F401
+except ImportError as err:
+ raise unittest.SkipTest(err)
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 2ff569ddb..2182f2bbc 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_block_quotes.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_block_quotes.py
@@ -24,14 +24,10 @@ if __name__ == '__main__':
sys.path.insert(0, str(Path(__file__).resolve().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()
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 a94f68d47..9bca916d5 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_bullet_lists.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_bullet_lists.py
@@ -24,14 +24,10 @@ if __name__ == '__main__':
sys.path.insert(0, str(Path(__file__).resolve().parents[3]))
from docutils.frontend import get_default_settings
-try:
- from docutils.parsers.recommonmark_wrapper import Parser
-except ImportError:
- Parser = None
+from docutils.parsers.recommonmark_wrapper import Parser
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()
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 cea4e8782..580562b01 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_enumerated_lists.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_enumerated_lists.py
@@ -23,14 +23,10 @@ if __name__ == '__main__':
sys.path.insert(0, str(Path(__file__).resolve().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()
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 727e6d150..3ee6bf4ce 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_html_blocks.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_html_blocks.py
@@ -24,14 +24,10 @@ if __name__ == '__main__':
sys.path.insert(0, str(Path(__file__).resolve().parents[3]))
from docutils.frontend import get_default_settings
-try:
- from docutils.parsers.recommonmark_wrapper import Parser
-except ImportError:
- Parser = None
+from docutils.parsers.recommonmark_wrapper import Parser
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()
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 dddac8bff..ee891b36d 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_inline_markup.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_inline_markup.py
@@ -23,14 +23,10 @@ if __name__ == '__main__':
sys.path.insert(0, str(Path(__file__).resolve().parents[3]))
from docutils.frontend import get_default_settings
-try:
- from docutils.parsers.recommonmark_wrapper import Parser
-except ImportError:
- Parser = None
+from docutils.parsers.recommonmark_wrapper import Parser
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()
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 e0a13a53a..76cd829dc 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
@@ -24,14 +24,10 @@ if __name__ == '__main__':
sys.path.insert(0, str(Path(__file__).resolve().parents[3]))
from docutils.frontend import get_default_settings
-try:
- from docutils.parsers.recommonmark_wrapper import Parser
-except ImportError:
- Parser = None
+from docutils.parsers.recommonmark_wrapper import Parser
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()
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 cdcf3d860..a0e46285d 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
@@ -25,14 +25,10 @@ if __name__ == '__main__':
sys.path.insert(0, str(Path(__file__).resolve().parents[3]))
from docutils.frontend import get_default_settings
-try:
- from docutils.parsers.recommonmark_wrapper import Parser
-except ImportError:
- Parser = None
+from docutils.parsers.recommonmark_wrapper import Parser
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()
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 2325a378f..692f9e9eb 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_literal_blocks.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_literal_blocks.py
@@ -24,14 +24,10 @@ if __name__ == '__main__':
sys.path.insert(0, str(Path(__file__).resolve().parents[3]))
from docutils.frontend import get_default_settings
-try:
- from docutils.parsers.recommonmark_wrapper import Parser
-except ImportError:
- Parser = None
+from docutils.parsers.recommonmark_wrapper import Parser
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()
diff --git a/docutils/test/test_parsers/test_recommonmark/test_misc.py b/docutils/test/test_parsers/test_recommonmark/test_misc.py
index e092c6ed8..c9e7f441f 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_misc.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_misc.py
@@ -24,10 +24,7 @@ if __name__ == '__main__':
from docutils.core import publish_string
from docutils.parsers.rst import directives as rst_directives
-try:
- from docutils.parsers.recommonmark_wrapper import Parser
-except ImportError:
- Parser = None
+from docutils.parsers.recommonmark_wrapper import Parser
sample_with_html = """\
diff --git a/docutils/test/test_parsers/test_recommonmark/test_paragraphs.py b/docutils/test/test_parsers/test_recommonmark/test_paragraphs.py
index 775a861e1..7e6d4c93c 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_paragraphs.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_paragraphs.py
@@ -18,14 +18,10 @@ if __name__ == '__main__':
sys.path.insert(0, str(Path(__file__).resolve().parents[3]))
from docutils.frontend import get_default_settings
-try:
- from docutils.parsers.recommonmark_wrapper import Parser
-except ImportError:
- Parser = None
+from docutils.parsers.recommonmark_wrapper import Parser
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()
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 853001a32..b2c36efc9 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_section_headers.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_section_headers.py
@@ -24,14 +24,10 @@ if __name__ == '__main__':
from docutils.frontend import get_default_settings
-try:
- from docutils.parsers.recommonmark_wrapper import Parser
-except ImportError:
- Parser = None
+from docutils.parsers.recommonmark_wrapper import Parser
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()
diff --git a/docutils/test/test_parsers/test_recommonmark/test_targets.py b/docutils/test/test_parsers/test_recommonmark/test_targets.py
index 75fd89cc0..639099381 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_targets.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_targets.py
@@ -24,14 +24,10 @@ if __name__ == '__main__':
from docutils.frontend import get_default_settings
-try:
- from docutils.parsers.recommonmark_wrapper import Parser
-except ImportError:
- Parser = None
+from docutils.parsers.recommonmark_wrapper import Parser
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()
diff --git a/docutils/test/test_parsers/test_recommonmark/test_transitions.py b/docutils/test/test_parsers/test_recommonmark/test_transitions.py
index 1110a6302..320593cf9 100755
--- a/docutils/test/test_parsers/test_recommonmark/test_transitions.py
+++ b/docutils/test/test_parsers/test_recommonmark/test_transitions.py
@@ -17,16 +17,11 @@ if __name__ == '__main__':
# so we import the local `docutils` package.
sys.path.insert(0, str(Path(__file__).resolve().parents[3]))
-
from docutils.frontend import get_default_settings
-try:
- from docutils.parsers.recommonmark_wrapper import Parser
-except ImportError:
- Parser = None
+from docutils.parsers.recommonmark_wrapper import Parser
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()