diff options
author | Waylan Limberg <waylan.limberg@icloud.com> | 2020-10-08 14:21:50 -0400 |
---|---|---|
committer | Waylan Limberg <waylan.limberg@icloud.com> | 2020-10-08 14:38:16 -0400 |
commit | 6525e21c7f4fc7533e7135bd880d9ddeaf6bd817 (patch) | |
tree | 9d5510a9bb16fe127581a1b89a702eef0fffa95c | |
parent | c0b1dc5d315624799ac1ba380eced9838e7f4bca (diff) | |
download | python-markdown-6525e21c7f4fc7533e7135bd880d9ddeaf6bd817.tar.gz |
Some test tweaks.
* Pygments specific tests now only run when the pygments version installed
matches the expected version. That version is defined in an environment
variable (PYGMENTS_VERSION) in the 'pygments' tox env (see #1030).
* When the Python lib tidylib is installed but the underlying c lib is not,
the relevant tests are now skipped rather than fail. This matches the
behavior when the Python lib is not installed. The tox envs are now useful
on systems which don't have the c lib installed.
-rw-r--r-- | markdown/test_tools.py | 7 | ||||
-rw-r--r-- | tests/test_syntax/extensions/test_fenced_code.py | 7 | ||||
-rw-r--r-- | tox.ini | 4 |
3 files changed, 14 insertions, 4 deletions
diff --git a/markdown/test_tools.py b/markdown/test_tools.py index fb407bb..5f33619 100644 --- a/markdown/test_tools.py +++ b/markdown/test_tools.py @@ -140,8 +140,11 @@ class LegacyTestMeta(type): expected = f.read().replace("\r\n", "\n") output = markdown(input, **kwargs) if tidylib and normalize: - expected = _normalize_whitespace(expected) - output = _normalize_whitespace(output) + try: + expected = _normalize_whitespace(expected) + output = _normalize_whitespace(output) + except OSError: + self.skipTest("Tidylib's c library not available.") elif normalize: self.skipTest('Tidylib not available.') self.assertMultiLineEqual(output, expected) diff --git a/tests/test_syntax/extensions/test_fenced_code.py b/tests/test_syntax/extensions/test_fenced_code.py index c86a733..a78c18c 100644 --- a/tests/test_syntax/extensions/test_fenced_code.py +++ b/tests/test_syntax/extensions/test_fenced_code.py @@ -21,14 +21,19 @@ License: BSD (see LICENSE.md for details). from markdown.test_tools import TestCase import markdown +import os class TestFencedCode(TestCase): def setUp(self): - self.has_pygments = True + # Only set self.has_pygments to True if pygments is installed and the version matches + # the version expected by the tests. The version expected by the tests is the version + # specified and installed in the 'pygments' tox env. Outside of the tox env, an environment + # variable named PYGMENTS_VERSION will need to be defined to force the tests to use pygments. try: import pygments # noqa + self.has_pygments = pygments.__version__ == os.environ.get('PYGMENTS_VERSION', '') except ImportError: self.has_pygments = False @@ -12,9 +12,11 @@ commands = [testenv:pygments] # Run tests with pygments installed (override deps only). +setenv = + PYGMENTS_VERSION = 2.7.1 deps = pytidylib - pygments==2.7.1 + pygments=={env:PYGMENTS_VERSION} [testenv:flake8] deps = flake8 |