|
From: <aa-...@us...> - 2022-11-10 16:54:47
|
Revision: 9237
http://sourceforge.net/p/docutils/code/9237
Author: aa-turner
Date: 2022-11-10 16:54:38 +0000 (Thu, 10 Nov 2022)
Log Message:
-----------
Add support for ``pytest``
This is the minimal configuration required for the test suite to
pass using the pytest framework. This is part of the test suite
refactoring project.
- Ignore two classes that start with the word "Test"
- Provide the standard test header to pytest
- Update the documentation
Modified Paths:
--------------
trunk/docutils/docs/dev/testing.txt
trunk/docutils/docutils/transforms/universal.py
trunk/docutils/test/test_transforms/test___init__.py
Added Paths:
-----------
trunk/docutils/test/conftest.py
Modified: trunk/docutils/docs/dev/testing.txt
===================================================================
--- trunk/docutils/docs/dev/testing.txt 2022-11-10 16:25:32 UTC (rev 9236)
+++ trunk/docutils/docs/dev/testing.txt 2022-11-10 16:54:38 UTC (rev 9237)
@@ -39,16 +39,16 @@
__ 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_.
+ The standard ``alltests.py`` test runner uses the standard library's
+ unittest_ framework.
+ For the pytest_ test framework, from a shell run::
+
+ pytest --quiet ./test
+
.. _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.
Modified: trunk/docutils/docutils/transforms/universal.py
===================================================================
--- trunk/docutils/docutils/transforms/universal.py 2022-11-10 16:25:32 UTC (rev 9236)
+++ trunk/docutils/docutils/transforms/universal.py 2022-11-10 16:54:38 UTC (rev 9237)
@@ -172,6 +172,9 @@
Used for testing purposes.
"""
+ # marker for pytest to ignore this class during test discovery
+ __test__ = False
+
default_priority = 880
def apply(self):
Added: trunk/docutils/test/conftest.py
===================================================================
--- trunk/docutils/test/conftest.py (rev 0)
+++ trunk/docutils/test/conftest.py 2022-11-10 16:54:38 UTC (rev 9237)
@@ -0,0 +1,21 @@
+def pytest_report_header(config):
+ import os
+ import platform
+ import sys
+ import time
+
+ # DocutilsTestSupport must be imported before docutils
+ from . import DocutilsTestSupport # NoQA: F401
+ import docutils
+
+ return '\n'.join((
+ '',
+ f'Testing Docutils {docutils.__version__} '
+ f'with Python {sys.version.split()[0]} '
+ f'on {time.strftime("%Y-%m-%d at %H:%M:%S")}',
+ f'OS: {platform.system()} {platform.release()} {platform.version()} '
+ f'({sys.platform}, {platform.platform()})',
+ f'Working directory: {os.getcwd()}',
+ f'Docutils package: {os.path.dirname(docutils.__file__)}',
+ '',
+ ))
Modified: trunk/docutils/test/test_transforms/test___init__.py
===================================================================
--- trunk/docutils/test/test_transforms/test___init__.py 2022-11-10 16:25:32 UTC (rev 9236)
+++ trunk/docutils/test/test_transforms/test___init__.py 2022-11-10 16:54:38 UTC (rev 9237)
@@ -15,6 +15,9 @@
class TestTransform(transforms.Transform):
+ # marker for pytest to ignore this class during test discovery
+ __test__ = False
+
default_priority = 100
applied = 0
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|