|
From: <mi...@us...> - 2022-01-12 15:57:22
|
Revision: 8945
http://sourceforge.net/p/docutils/code/8945
Author: milde
Date: 2022-01-12 15:57:19 +0000 (Wed, 12 Jan 2022)
Log Message:
-----------
Document incompatibility with "pytest" and "nosetest". Update.
Triggered by [feature-request:#81].
Use PEP 3102 syntax instead of reading/deleting "**kwargs" items
for "required keyword arguments".
Modified Paths:
--------------
trunk/docutils/docs/dev/testing.txt
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/test_functional.py
trunk/docutils/test/test_language.py
Modified: trunk/docutils/docs/dev/testing.txt
===================================================================
--- trunk/docutils/docs/dev/testing.txt 2022-01-12 15:57:09 UTC (rev 8944)
+++ trunk/docutils/docs/dev/testing.txt 2022-01-12 15:57:19 UTC (rev 8945)
@@ -34,6 +34,19 @@
all `supported Python versions`_ (see below for details).
In a pinch, the edge cases should cover most of it.
+__ policies.html#check-ins
+
+.. note::
+ Due to incompatible customization of the standard unittest_
+ framework, the test suite does not work with popular test frameworks
+ like pytest_ or nose_.
+
+ .. _unittest: https://docs.python.org/3/library/unittest.html
+ .. _pytest: https://pypi.org/project/pytest/
+ .. _nose: https://pypi.org/project/nose3/
+
+ .. cf. https://sourceforge.net/p/docutils/feature-requests/81/
+
.. [#] When using the `Python launcher for Windows`__, make sure to
specify a Python version, e.g., ``py -3.9 -u alltests.py`` for
Python 3.9.
@@ -42,9 +55,7 @@
.. cf. https://sourceforge.net/p/docutils/bugs/434/
-__ policies.html#check-ins
-
.. _Python versions:
Testing across multiple Python versions
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2022-01-12 15:57:09 UTC (rev 8944)
+++ trunk/docutils/test/DocutilsTestSupport.py 2022-01-12 15:57:19 UTC (rev 8945)
@@ -103,6 +103,9 @@
"""
Helper class, providing the same interface as unittest.TestCase,
but with useful setUp and comparison methods.
+
+ The methods assertEqual and assertNotEqual have been overwritten
+ to provide better support for multi-line strings.
"""
def setUp(self):
@@ -136,11 +139,12 @@
"""
Helper class, providing extended functionality over unittest.TestCase.
- The methods assertEqual and assertNotEqual have been overwritten
- to provide better support for multi-line strings. Furthermore,
- see the compare_output method and the parameter list of __init__.
- """
+ See the compare_output method and the parameter list of __init__.
+ Note: the modified signature is incompatible with
+ the "pytest" and "nose" frameworks.
+ """ # cf. feature-request #81
+
compare = difflib.Differ().compare
"""Comparison method shared by all subclasses."""
@@ -162,7 +166,7 @@
self.input = input
self.expected = expected
self.run_in_debugger = run_in_debugger
- self.suite_settings = suite_settings.copy() or {}
+ self.suite_settings = suite_settings.copy() if suite_settings else {}
super().__init__(method_name)
@@ -316,18 +320,19 @@
settings.warning_stream = DevNull()
unknown_reference_resolvers = ()
- def __init__(self, *args, **kwargs):
- self.transforms = kwargs['transforms']
+ def __init__(self, *args, parser=None, transforms=None, **kwargs):
+ assert transforms is not None, 'required argument'
+ self.transforms = transforms
"""List of transforms to perform for this test case."""
- self.parser = kwargs['parser']
+ assert parser is not None, 'required argument'
+ self.parser = parser
"""Input parser for this test case."""
- del kwargs['transforms'], kwargs['parser'] # only wanted here
CustomTestCase.__init__(self, *args, **kwargs)
def supports(self, format):
- return 1
+ return True
def test_transforms(self):
if self.run_in_debugger:
@@ -536,7 +541,7 @@
"""A collection of RecommonmarkParserTestCases."""
test_case_class = RecommonmarkParserTestCase
-
+
if not test_case_class.parser_class:
# print('No compatible CommonMark parser found.'
# ' Skipping all CommonMark/recommonmark tests.')
@@ -660,11 +665,10 @@
'strict_visitor': True}
writer_name = '' # set in subclasses or constructor
- def __init__(self, *args, **kwargs):
- if 'writer_name' in kwargs:
- self.writer_name = kwargs['writer_name']
- del kwargs['writer_name']
- CustomTestCase.__init__(self, *args, **kwargs)
+ def __init__(self, *args, writer_name='', **kwargs):
+ if writer_name:
+ self.writer_name = writer_name
+ super().__init__(*args, **kwargs)
def test_publish(self):
if self.run_in_debugger:
Modified: trunk/docutils/test/test_functional.py
===================================================================
--- trunk/docutils/test/test_functional.py 2022-01-12 15:57:09 UTC (rev 8944)
+++ trunk/docutils/test/test_functional.py 2022-01-12 15:57:19 UTC (rev 8945)
@@ -88,12 +88,20 @@
svn add %(exp)s
svn commit -m "<comment>" %(exp)s"""
- def __init__(self, *args, **kwargs):
- """Set self.configfile, pass arguments to parent __init__."""
- self.configfile = kwargs['configfile']
- del kwargs['configfile']
- DocutilsTestSupport.CustomTestCase.__init__(self, *args, **kwargs)
+ def __init__(self, *args, configfile=None, **kwargs):
+ """
+ Set self.configfile, pass remaining arguments to parent.
+ Requires keyword argument `configfile`.
+
+ Note: the modified signature is incompatible with
+ the "pytest" and "nose" frameworks.
+ """ # cf. feature-request #81
+
+ assert configfile is not None, 'required argument'
+ self.configfile = configfile
+ super().__init__(*args, **kwargs)
+
def shortDescription(self):
return 'test_functional.py: ' + self.configfile
Modified: trunk/docutils/test/test_language.py
===================================================================
--- trunk/docutils/test/test_language.py 2022-01-12 15:57:09 UTC (rev 8944)
+++ trunk/docutils/test/test_language.py 2022-01-12 15:57:19 UTC (rev 8945)
@@ -72,12 +72,22 @@
'test_directives', 'test_roles']
"""Names of methods used to test each language."""
- def __init__(self, *args, **kwargs):
+ def __init__(self, *args, language=None, **kwargs):
+ """
+ Set self.ref (from module variable) and self.language.
+
+ Requires keyword argument `language`.
+ Pass remaining arguments to parent __init__.
+
+ Note: the modified signature is incompatible with
+ the "pytest" and "nose" frameworks.
+ """ # cf. feature-request #81
+
self.ref = docutils.languages.get_language(reference_language,
_reporter)
- self.language = kwargs['language']
- del kwargs['language'] # only wanted here
- DocutilsTestSupport.CustomTestCase.__init__(self, *args, **kwargs)
+ assert language is not None, 'required argument'
+ self.language = language
+ super().__init__(*args, **kwargs)
def _xor(self, ref_dict, l_dict):
"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|