_camelcase_to_snakecase = re.compile('((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))')
def doxygen_version():
- return subprocess.check_output(['doxygen', '-v']).decode('utf-8').strip()
+ return subprocess.check_output(['doxygen', '-v']).decode('utf-8').strip().split(' ')[0]
+
+# A copy of the same utility that's in plugins/m/test/__init__.py because
+# distutils is deprecated and alternatives are insane. See there for details.
+def parse_version(string: str):
+ return tuple([int(i) for i in string.split('.')])
class BaseTestCase(unittest.TestCase):
def __init__(self, *args, dir=None, **kwargs):
import os
import unittest
-from distutils.version import LooseVersion
-
-from . import IntegrationTestCase, doxygen_version
+from . import IntegrationTestCase, doxygen_version, parse_version
class Listing(IntegrationTestCase):
def test_index_pages(self):
# The namespace should have the detailed docs
self.assertEqual(*self.actual_expected_contents('namespaceNamespace.html'))
- @unittest.skipUnless(LooseVersion(doxygen_version()) > LooseVersion("1.8.14"),
+ @unittest.skipUnless(parse_version(doxygen_version()) > parse_version("1.8.14"),
"https://github.com/doxygen/doxygen/pull/653")
def test_file(self):
self.run_doxygen(wildcard='File_8h.xml')
self.assertEqual(*self.actual_expected_contents('File_8h.html'))
class NamespaceMembersInFileScopeDefineBaseUrl(IntegrationTestCase):
- @unittest.skipUnless(LooseVersion(doxygen_version()) > LooseVersion("1.8.14"),
+ @unittest.skipUnless(parse_version(doxygen_version()) > parse_version("1.8.14"),
"https://github.com/doxygen/doxygen/pull/653")
def test(self):
self.run_doxygen(wildcard='File_8h.xml')
from hashlib import sha1
-from distutils.version import LooseVersion
-
-from . import BaseTestCase, IntegrationTestCase, doxygen_version
+from . import BaseTestCase, IntegrationTestCase, doxygen_version, parse_version
def dot_version():
return re.match(".*version (?P<version>\d+\.\d+\.\d+).*", subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT).decode('utf-8').strip()).group('version')
self.run_doxygen(wildcard='indexpage.xml')
self.assertEqual(*self.actual_expected_contents('index.html'))
- @unittest.skipUnless(LooseVersion(doxygen_version()) > LooseVersion("1.8.17"), "new features in 1.8.17")
+ @unittest.skipUnless(parse_version(doxygen_version()) > parse_version("1.8.17"), "new features in 1.8.17")
def test_1817(self):
self.run_doxygen(wildcard='doxygen1817.xml')
self.assertEqual(*self.actual_expected_contents('doxygen1817.html'))
# Multiple xrefitems should be merged into one
self.assertEqual(*self.actual_expected_contents('File_8h.html'))
- @unittest.skipUnless(LooseVersion(doxygen_version()) > LooseVersion("1.8.18"), "new features in 1.8.18")
+ @unittest.skipUnless(parse_version(doxygen_version()) > parse_version("1.8.18"), "new features in 1.8.18")
def test_1818(self):
self.run_doxygen(wildcard='*.xml')
self.assertEqual(*self.actual_expected_contents('doxygen1818.html'))
def test_xrefitem(self):
self.run_doxygen(wildcard='*.xml')
- if LooseVersion(doxygen_version()) > LooseVersion("1.8.14"):
+ if parse_version(doxygen_version()) > parse_version("1.8.14"):
self.assertEqual(*self.actual_expected_contents('todo.html'))
# https://github.com/doxygen/doxygen/pull/6587 fucking broke this
else:
self.assertEqual(*self.actual_expected_contents('todo.html', 'todo_1814.html'))
# 1.8.18 to 1.8.20 has a different order, not sure why
- if LooseVersion(doxygen_version()) >= LooseVersion("1.8.18") and LooseVersion(doxygen_version()) < LooseVersion("1.9.0"):
+ if parse_version(doxygen_version()) >= parse_version("1.8.18") and parse_version(doxygen_version()) < parse_version("1.9.0"):
self.assertEqual(*self.actual_expected_contents('old.html', 'old_1818.html'))
- elif LooseVersion(doxygen_version()) > LooseVersion("1.8.14"):
+ elif parse_version(doxygen_version()) > parse_version("1.8.14"):
self.assertEqual(*self.actual_expected_contents('old.html'))
else:
self.assertEqual(*self.actual_expected_contents('old.html', 'old_1814.html'))
])
class CodeLanguage(IntegrationTestCase):
- @unittest.skipUnless(LooseVersion(doxygen_version()) > LooseVersion("1.8.13"),
+ @unittest.skipUnless(parse_version(doxygen_version()) > parse_version("1.8.13"),
"https://github.com/doxygen/doxygen/pull/621")
def test(self):
self.run_doxygen(wildcard='indexpage.xml')
self.assertEqual(*self.actual_expected_contents('index.html'))
- @unittest.skipUnless(LooseVersion(doxygen_version()) > LooseVersion("1.8.13"),
+ @unittest.skipUnless(parse_version(doxygen_version()) > parse_version("1.8.13"),
"https://github.com/doxygen/doxygen/pull/623")
def test_ansi(self):
self.run_doxygen(wildcard='ansi.xml')
self.assertEqual(*self.actual_expected_contents('ansi.html'))
- @unittest.skipUnless(LooseVersion(doxygen_version()) > LooseVersion("1.8.13"),
+ @unittest.skipUnless(parse_version(doxygen_version()) > parse_version("1.8.13"),
"https://github.com/doxygen/doxygen/pull/621")
def test_warnings(self):
with self.assertLogs() as cm:
"WARNING:root:warnings.xml: image nonexistent.png was not found in XML_OUTPUT"
])
- @unittest.skipUnless(LooseVersion(doxygen_version()) > LooseVersion("1.8.15"),
+ @unittest.skipUnless(parse_version(doxygen_version()) > parse_version("1.8.15"),
"fully fixed after 1.8.15")
def test_imagelink(self):
self.run_doxygen(wildcard='imagelink.xml')
self.run_doxygen(wildcard='dot.xml')
# Used to be >= 2.44.0, but 2.42.2 appears to have the same output
- if LooseVersion(dot_version()) >= LooseVersion("2.42.2"):
+ if parse_version(dot_version()) >= parse_version("2.42.2"):
file = 'dot.html'
else:
file = 'dot-240.html'
# properly.
class AutobriefHr(IntegrationTestCase):
- @unittest.skipUnless(LooseVersion(doxygen_version()) < LooseVersion("1.8.15"),
+ @unittest.skipUnless(parse_version(doxygen_version()) < parse_version("1.8.15"),
"1.8.15 doesn't put <hruler> into <briefdescription> anymore")
def test_1814(self):
with self.assertLogs() as cm:
"WARNING:root:namespaceNamespace.xml: JAVADOC_AUTOBRIEF / QT_AUTOBRIEF produced a brief description with block elements. That's not supported, ignoring the whole contents of <hr/>"
])
- @unittest.skipUnless(LooseVersion(doxygen_version()) >= LooseVersion("1.8.15"),
+ @unittest.skipUnless(parse_version(doxygen_version()) >= parse_version("1.8.15"),
"1.8.15 doesn't put <hruler> into <briefdescription> anymore")
def test(self):
# No warnings should be produced here
])
class AutobriefHeading(IntegrationTestCase):
- @unittest.skipUnless(LooseVersion(doxygen_version()) < LooseVersion("1.8.15"),
+ @unittest.skipUnless(parse_version(doxygen_version()) < parse_version("1.8.15"),
"1.8.15 doesn't put <heading> into <briefdescription> anymore")
def test_1814(self):
with self.assertLogs() as cm:
"WARNING:root:namespaceNamespace.xml: JAVADOC_AUTOBRIEF / QT_AUTOBRIEF produced a brief description with block elements. That's not supported, ignoring the whole contents of <p>===============</p><h4>The Thing </h4>",
])
- @unittest.skipUnless(LooseVersion(doxygen_version()) >= LooseVersion("1.8.15"),
+ @unittest.skipUnless(parse_version(doxygen_version()) >= parse_version("1.8.15"),
"1.8.15 doesn't put <heading> into <briefdescription> anymore")
def test(self):
# No warnings should be produced here
self.assertEqual(*self.actual_expected_contents('namespaceNamespace.html'))
class BriefMultilineIngroup(IntegrationTestCase):
- @unittest.skipUnless(LooseVersion(doxygen_version()) < LooseVersion("1.8.16"),
+ @unittest.skipUnless(parse_version(doxygen_version()) < parse_version("1.8.16"),
"1.8.16 doesn't merge adjacent paragraphs into brief in presence of an @ingroup anymore")
def test_1815(self):
with self.assertLogs() as cm:
"WARNING:root:group__thatgroup.xml: ignoring brief description containing multiple paragraphs. Please modify your markup to remove any block elements from the following: <p>Function that's in a group</p><p>Lines of detailed description that get merged to the brief for no freaking reason.</p>"
])
- @unittest.skipUnless(LooseVersion(doxygen_version()) >= LooseVersion("1.8.16"),
+ @unittest.skipUnless(parse_version(doxygen_version()) >= parse_version("1.8.16"),
"1.8.16 doesn't merge adjacent paragraphs into brief in presence of an @ingroup anymore")
def test(self):
# No warnings should be produced here
self.run_doxygen(wildcard='indexpage.xml')
# Used to be >= 2.44.0, but 2.42.2 appears to have the same output
- if LooseVersion(dot_version()) >= LooseVersion("2.42.2"):
+ if parse_version(dot_version()) >= parse_version("2.42.2"):
file = 'index.html'
else:
file = 'index-240.html'
self.assertEqual(*self.actual_expected_contents('index.html', file))
- @unittest.skipUnless(LooseVersion(doxygen_version()) >= LooseVersion("1.8.16"),
+ @unittest.skipUnless(parse_version(doxygen_version()) >= parse_version("1.8.16"),
"1.8.16+ drops the whole <dotfile> tag if the file doesn't exist, which is incredibly dumb")
def test_warnings(self):
# No warnings should be produced here
self.run_doxygen(wildcard='warnings.xml')
self.assertEqual(*self.actual_expected_contents('warnings.html'))
- @unittest.skipUnless(LooseVersion(doxygen_version()) < LooseVersion("1.8.16"),
+ @unittest.skipUnless(parse_version(doxygen_version()) < parse_version("1.8.16"),
"1.8.16+ drops the whole <dotfile> tag if the file doesn't exist, which is incredibly dumb")
def test_warnings_1815(self):
with self.assertLogs() as cm:
self.run_doxygen(wildcard='indexpage.xml')
self.assertEqual(*self.actual_expected_contents('index.html'))
- @unittest.skipUnless(LooseVersion(doxygen_version()) >= LooseVersion("1.8.18"),
+ @unittest.skipUnless(parse_version(doxygen_version()) >= parse_version("1.8.18"),
"1.8.17 and older doesn't include @htmlonly in XML output")
def test_htmlonly(self):
self.run_doxygen(wildcard='html-only.xml')
import unittest
-from distutils.version import LooseVersion
-
-from . import IntegrationTestCase, doxygen_version
+from . import IntegrationTestCase, doxygen_version, parse_version
class EnumClass(IntegrationTestCase):
- @unittest.skipUnless(LooseVersion(doxygen_version()) > LooseVersion("1.8.13"),
+ @unittest.skipUnless(parse_version(doxygen_version()) > parse_version("1.8.13"),
"https://github.com/doxygen/doxygen/pull/627")
def test(self):
self.run_doxygen(wildcard='File_8h.xml')
self.assertEqual(*self.actual_expected_contents('File_8h.html'))
class TemplateAlias(IntegrationTestCase):
- @unittest.skipUnless(LooseVersion(doxygen_version()) > LooseVersion("1.8.13"),
+ @unittest.skipUnless(parse_version(doxygen_version()) > parse_version("1.8.13"),
"https://github.com/doxygen/doxygen/pull/626")
def test(self):
self.run_doxygen(wildcard='*.xml')
self.assertEqual(*self.actual_expected_contents('annotated.html'))
class Friends(IntegrationTestCase):
- @unittest.skipUnless(LooseVersion(doxygen_version()) > LooseVersion("1.8.13"),
+ @unittest.skipUnless(parse_version(doxygen_version()) > parse_version("1.8.13"),
"1.8.13 produces invalid XML for friend declarations")
def test(self):
self.run_doxygen(wildcard='class*.xml')
import unittest
-from distutils.version import LooseVersion
-
-from . import IntegrationTestCase, doxygen_version
+from . import IntegrationTestCase, doxygen_version, parse_version
class Example(IntegrationTestCase):
def test_cpp(self):
self.assertEqual(*self.actual_expected_contents('path-prefix_2configure_8h_8cmake-example.html'))
self.assertEqual(*self.actual_expected_contents('path-prefix_2main_8cpp-example.html'))
- @unittest.skipUnless(LooseVersion(doxygen_version()) > LooseVersion("1.8.13"),
+ @unittest.skipUnless(parse_version(doxygen_version()) > parse_version("1.8.13"),
"needs to have file extension exposed in the XML")
def test_other(self):
self.run_doxygen(index_pages=[], wildcard='*.xml')
import os
import unittest
-from distutils.version import LooseVersion
-
-from . import IntegrationTestCase, doxygen_version
+from . import IntegrationTestCase, doxygen_version, parse_version
class Order(IntegrationTestCase):
def test(self):
self.assertEqual(*self.actual_expected_contents('pages.html'))
class Brief(IntegrationTestCase):
- @unittest.skipUnless(LooseVersion(doxygen_version()) > LooseVersion("1.8.13"),
+ @unittest.skipUnless(parse_version(doxygen_version()) > parse_version("1.8.13"),
"https://github.com/doxygen/doxygen/pull/624")
def test(self):
self.run_doxygen(wildcard='*.xml')
self.assertEqual(*self.actual_expected_contents('page-b.html'))
class Toc(IntegrationTestCase):
- @unittest.skipUnless(LooseVersion(doxygen_version()) > LooseVersion("1.8.13"),
+ @unittest.skipUnless(parse_version(doxygen_version()) > parse_version("1.8.13"),
"https://github.com/doxygen/doxygen/pull/625")
def test(self):
self.run_doxygen(wildcard='page-toc.xml')
self.assertEqual(*self.actual_expected_contents('untitled.html'))
class SubpageOfIndex(IntegrationTestCase):
- @unittest.skipUnless(LooseVersion(doxygen_version()) >= LooseVersion("1.8.17"),
+ @unittest.skipUnless(parse_version(doxygen_version()) >= parse_version("1.8.17"),
"1.8.16 and below doesn't mark the page as subpage of index")
def test(self):
self.run_doxygen(wildcard='*.xml')
# https://stackoverflow.com/a/12867228
_camelcase_to_snakecase = re.compile('((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))')
+# A copy of the same utility that's in plugins/m/test/__init__.py because
+# distutils is deprecated and alternatives are insane. See there for details.
+def parse_version(string: str):
+ return tuple([int(i) for i in string.split('.')])
+
# The test files are automatically detected from derived class name and
# filesystem location. For a `test_inspect.NameMapping` class, it will look
# for the `inspect_name_mapping` directory. If the class name is equivalent to
import sys
import unittest
-from distutils.version import LooseVersion
-
from python import default_templates
-from . import BaseInspectTestCase
+from . import BaseInspectTestCase, parse_version
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../plugins'))
import m.sphinx
class Annotations(BaseInspectTestCase):
def test(self):
self.run_python()
- if LooseVersion(sys.version) >= LooseVersion('3.7.0') and LooseVersion(sys.version) < LooseVersion('3.9.0'):
+ if sys.version_info >= (3, 7) and sys.version_info < (3, 9):
self.assertEqual(*self.actual_expected_contents('inspect_annotations.html', 'inspect_annotations-py37+38.html'))
else:
self.assertEqual(*self.actual_expected_contents('inspect_annotations.html'))
# This should not list any internal stuff from the typing module. The
# Generic.__new__() is gone in 3.9: https://bugs.python.org/issue39168
- if LooseVersion(sys.version) >= LooseVersion('3.9.0'):
+ if sys.version_info >= (3, 9):
self.assertEqual(*self.actual_expected_contents('inspect_annotations.AContainer.html'))
else:
self.assertEqual(*self.actual_expected_contents('inspect_annotations.AContainer.html', 'inspect_annotations.AContainer-py36-38.html'))
# https://github.com/python/cpython/pull/13394
- @unittest.skipUnless(LooseVersion(sys.version) >= LooseVersion('3.7.4'),
+ @unittest.skipUnless(sys.version_info >= (3, 7, 4),
"signature with / for pow() is not present in 3.6, "
"3.7.3 and below has a different docstring")
def test_math(self):
self.assertEqual(*self.actual_expected_contents('math.html'))
# https://github.com/python/cpython/pull/13394
- @unittest.skipUnless(LooseVersion(sys.version) < LooseVersion('3.7.4') and LooseVersion(sys.version) >= LooseVersion('3.7'),
+ @unittest.skipUnless(sys.version_info < (3, 7, 4) and sys.version_info >= (3, 7),
"signature with / for pow() is not present in 3.6, "
"3.7.3 and below has a different docstring")
def test_math373(self):
self.assertEqual(*self.actual_expected_contents('math.html', 'math373.html'))
- @unittest.skipUnless(LooseVersion(sys.version) < LooseVersion('3.7'),
+ @unittest.skipUnless(sys.version_info < (3, 7),
"docstring for log() is different in 3.7")
def test_math36(self):
# From math export only pow() so we have the verification easier, and
import re
import subprocess
-from distutils.version import LooseVersion
-
-from . import BaseTestCase
+from . import BaseTestCase, parse_version
def dot_version():
return re.match(".*version (?P<version>\d+\.\d+\.\d+).*", subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT).decode('utf-8').strip()).group('version')
self.assertEqual(*self.actual_expected_contents('index.html'))
# Used to be >= 2.44.0, but 2.42.2 appears to have the same output
- if LooseVersion(dot_version()) >= LooseVersion("2.42.2"):
+ if parse_version(dot_version()) >= parse_version("2.42.2"):
file = 'dot.html'
else:
file = 'dot-240.html'
# I assume this will be a MASSIVE ANNOYANCE at some point as well so
# keeping it separate. (Yes, thank you past mosra. Very helpful.)
- if LooseVersion(matplotlib.__version__) >= LooseVersion('3.5'):
+ if parse_version(matplotlib.__version__) >= parse_version('3.5'):
self.assertEqual(*self.actual_expected_contents('plots.html'))
- elif LooseVersion(matplotlib.__version__) >= LooseVersion('3.4'):
+ elif parse_version(matplotlib.__version__) >= parse_version('3.4'):
self.assertEqual(*self.actual_expected_contents('plots.html', 'plots-34.html'))
else:
self.assertEqual(*self.actual_expected_contents('plots.html', 'plots-32.html'))
from pelican import read_settings, Pelican
+# A copy of the same utility that's in plugins/m/test/__init__.py because
+# distutils is deprecated and alternatives are insane. See there for details.
+def parse_version(string: str):
+ return tuple([int(i) for i in string.split('.')])
+
class MinimalTestCase(unittest.TestCase):
def __init__(self, path, dir, *args, **kwargs):
unittest.TestCase.__init__(self, *args, **kwargs)
import pelican
-from distutils.version import LooseVersion
-
-from test import PageTestCase
+from . import PageTestCase, parse_version
class Page(PageTestCase):
def __init__(self, *args, **kwargs):
# Not merged for 4.7 yet and no time from my side to push the PR through,
# so let's defer this to blow up at some point in the future.
- @unittest.skipUnless(LooseVersion(pelican.__version__) > LooseVersion("5.0.0"),
+ @unittest.skipUnless(parse_version(pelican.__version__) > parse_version("5.0.0"),
"https://github.com/getpelican/pelican/pull/2260")
def test_content(self):
self.run_pelican({
from pelican import read_settings, Pelican
+# distutils is deprecated, so I can no longer use LooseVersion to compare
+# versions. The only sane alternative was pkg_resources, suggested at
+# https://stackoverflow.com/a/57634066, but that's now ALSO deprecated, and one
+# is instructed to INSTALL the packaging module in order to perform BASIC
+# functionality. Fuck off.
+#
+# This returns a tuple of integers which should behave as intended for most
+# cases, a corresponding test is in test.py. Copied to pelican-theme/test,
+# documentation/test_python/ and documentation/test_doxygen.
+def parse_version(string: str):
+ return tuple([int(i) for i in string.split('.')])
+
class PelicanPluginTestCase(unittest.TestCase):
def __init__(self, path, dir, *args, **kwargs):
unittest.TestCase.__init__(self, *args, **kwargs)
import subprocess
import unittest
-from distutils.version import LooseVersion
-
-from . import PelicanPluginTestCase
+from . import PelicanPluginTestCase, parse_version
def dot_version():
return re.match(".*version (?P<version>\d+\.\d+\.\d+).*", subprocess.check_output(['dot', '-V'], stderr=subprocess.STDOUT).decode('utf-8').strip()).group('version')
})
# Used to be >= 2.44.0, but 2.42.2 appears to have the same output
- if LooseVersion(dot_version()) >= LooseVersion("2.42.2"):
+ if parse_version(dot_version()) >= parse_version("2.42.2"):
file = 'page.html'
else:
file = 'page-240.html'
import sys
import unittest
-from distutils.version import LooseVersion
-
-from . import PelicanPluginTestCase
+from . import PelicanPluginTestCase, parse_version
class Plots(PelicanPluginTestCase):
def __init__(self, *args, **kwargs):
})
# FUCK this is annoying
- if LooseVersion(matplotlib.__version__) >= LooseVersion('3.5'):
+ if parse_version(matplotlib.__version__) >= parse_version('3.5'):
self.assertEqual(*self.actual_expected_contents('page.html'))
- elif LooseVersion(matplotlib.__version__) >= LooseVersion('3.4'):
+ elif parse_version(matplotlib.__version__) >= parse_version('3.4'):
self.assertEqual(*self.actual_expected_contents('page.html', 'page-34.html'))
- elif LooseVersion(matplotlib.__version__) >= LooseVersion('3.2'):
+ elif parse_version(matplotlib.__version__) >= parse_version('3.2'):
self.assertEqual(*self.actual_expected_contents('page.html', 'page-32.html'))
- elif LooseVersion(matplotlib.__version__) >= LooseVersion('3.0'):
+ elif parse_version(matplotlib.__version__) >= parse_version('3.0'):
self.assertEqual(*self.actual_expected_contents('page.html', 'page-30.html'))
else:
self.assertEqual(*self.actual_expected_contents('page.html', 'page-22.html'))
import sys
-from distutils.version import LooseVersion
-
from . import PelicanPluginTestCase
class Qr(PelicanPluginTestCase):
'PLUGINS': ['m.htmlsanity', 'm.qr']
})
- if LooseVersion(sys.version) >= LooseVersion("3.8"):
+ if sys.version_info >= (3, 8):
self.assertEqual(*self.actual_expected_contents('page.html', 'page.html'))
- elif LooseVersion(sys.version) >= LooseVersion("3.7"):
+ elif sys.version_info >= (3, 7):
self.assertEqual(*self.actual_expected_contents('page.html', 'page-py37.html'))
else:
self.assertEqual(*self.actual_expected_contents('page.html', 'page-py36.html'))