|
From: <mi...@us...> - 2021-11-05 11:10:58
|
Revision: 8879
http://sourceforge.net/p/docutils/code/8879
Author: milde
Date: 2021-11-05 11:10:55 +0000 (Fri, 05 Nov 2021)
Log Message:
-----------
Deprecation warning updates.
- Make `frontend.ConfigDeprecationWarning` a subclass of `FutureWarning`
as it is also intended for end users.
https://docs.python.org/3/library/warnings.html#warning-categories
- Update deprecation warning tests.
Modified Paths:
--------------
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docutils/frontend.py
trunk/docutils/test/test_io.py
trunk/docutils/test/test_settings.py
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2021-11-05 11:10:44 UTC (rev 8878)
+++ trunk/docutils/RELEASE-NOTES.txt 2021-11-05 11:10:55 UTC (rev 8879)
@@ -22,6 +22,8 @@
Drop support for Python 2.7, 3.5, and 3.6.
+Drop support for `old-format configuration files`_.
+
* `html5` writer:
- Stop setting the "footnote-reference" class value for footnote
@@ -71,9 +73,12 @@
* Remove the "html_writer" option of the ``buildhtml.py`` application
(obsoleted by "writer__").
+ __ docs/user/config.html#writer
+
+.. _old-format configuration files:
+ docs/user/config.html#old-format-configuration-files
.. _rst2html.py: docs/user/tools.html#rst2html-py
.. _reference name: docs/ref/rst/restructuredtext.html#reference-names
-__ docs/user/config.html#writer
.. _literal_block_env: docs/user/config.html#literal-block-env
.. _use_latex_citations: docs/user/config.html#use-latex-citations
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2021-11-05 11:10:44 UTC (rev 8878)
+++ trunk/docutils/docutils/frontend.py 2021-11-05 11:10:55 UTC (rev 8879)
@@ -866,5 +866,5 @@
return section_dict
-class ConfigDeprecationWarning(DeprecationWarning):
+class ConfigDeprecationWarning(FutureWarning):
"""Warning for deprecated configuration file features."""
Modified: trunk/docutils/test/test_io.py
===================================================================
--- trunk/docutils/test/test_io.py 2021-11-05 11:10:44 UTC (rev 8878)
+++ trunk/docutils/test/test_io.py 2021-11-05 11:10:55 UTC (rev 8879)
@@ -133,25 +133,7 @@
# raise AssertionError if data is not an unicode string
self.assertRaises(AssertionError, uniinput.decode, b'ja')
- def test_deprecation_warning(self):
- # Test deprecation warning of 'U' universal newlines mode.
- # TODO remove with 3.4 support end
- # Arrange
- import warnings
- with warnings.catch_warnings(record=True) as w:
- # Cause all warnings to always be triggered
- warnings.simplefilter("always", DeprecationWarning)
-
- # Act
- # Trigger a warning?
- io.FileInput(source_path='data/include.txt').close()
-
- # Assert
- self.assertEqual(len(w), 0, "Expected no warnings, got %s" %
- list(v.category for v in w))
-
-
class OutputTests(unittest.TestCase):
bdata = b'\xfc'
Modified: trunk/docutils/test/test_settings.py
===================================================================
--- trunk/docutils/test/test_settings.py 2021-11-05 11:10:44 UTC (rev 8878)
+++ trunk/docutils/test/test_settings.py 2021-11-05 11:10:55 UTC (rev 8879)
@@ -22,10 +22,6 @@
from docutils.parsers import rst
-warnings.filterwarnings(action='ignore',
- category=frontend.ConfigDeprecationWarning)
-
-
def fixpath(path):
return os.path.abspath(os.path.join(*(path.split('/'))))
@@ -85,6 +81,8 @@
"""Comparison method shared by all tests."""
def setUp(self):
+ warnings.filterwarnings(action='ignore',
+ category=frontend.ConfigDeprecationWarning)
self.option_parser = frontend.OptionParser(
components=(pep_html.Writer, rst.Parser), read_config_files=None)
@@ -123,8 +121,12 @@
self.expected_settings())
def test_old(self):
- self.compare_output(self.files_settings('old'),
- self.expected_settings('old'))
+ with warnings.catch_warnings(record=True) as wng:
+ warnings.simplefilter("always") # check also for deprecation warning
+ self.compare_output(self.files_settings('old'),
+ self.expected_settings('old'))
+ self.assertEqual(len(wng), 1, "Expected a FutureWarning.")
+ assert issubclass(wng[-1].category, FutureWarning)
def test_one(self):
self.compare_output(self.files_settings('one'),
@@ -283,6 +285,13 @@
frontend.validate_smartquotes_locales(None, t[0], None),
t[1])
+ def test_set_conditions_deprecation_warning(self):
+ reporter = utils.Reporter('test', 1, 4)
+ with warnings.catch_warnings(record=True) as wng:
+ warnings.simplefilter("always")
+ reporter.set_conditions('foo', 1, 4) # trigger warning
+ self.assertEqual(len(wng), 1, "Expected a DeprecationWarning.")
+ assert issubclass(wng[-1].category, DeprecationWarning)
if __name__ == '__main__':
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|