SF.net SVN: docutils:[9864] trunk/docutils/test/test_io.py

milde--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9864
          http://sourceforge.net/p/docutils/code/9864
Author:   milde
Date:     2024-08-07 15:56:42 +0000 (Wed, 07 Aug 2024)
Log Message:
-----------
Remove obsolete test for input encoding fallback.

Define a (never used) fallback for `EncodingWarning`
for Python 3.9 to keep flake8 happy.

Solves the test failure on non-UTF8 Windows mentioned in [bugs: #490].

Modified Paths:
--------------
    trunk/docutils/test/test_io.py

Modified: trunk/docutils/test/test_io.py
===================================================================
--- trunk/docutils/test/test_io.py	2024-08-07 14:05:58 UTC (rev 9863)
+++ trunk/docutils/test/test_io.py	2024-08-07 15:56:42 UTC (rev 9864)
@@ -27,10 +27,11 @@
 # For when we intentionally do things that trigger EncodingWarning
 # (When using ``-X warn_default_encoding`` or PYTHONWARNDEFAULTENCODING=1)
 # See: https://docs.python.org/3/library/io.html#io-encoding-warning
-SUPPRESS_ENCODING_WARNING = (
-    sys.version_info[:2] > (3, 9)
-    and sys.flags.warn_default_encoding
-)
+if sys.version_info[:2] > (3, 9):
+    SUPPRESS_ENCODING_WARNING = sys.flags.warn_default_encoding
+else:
+    SUPPRESS_ENCODING_WARNING = False
+    EncodingWarning = UnicodeWarning
 
 # DATA_ROOT is ./test/data/ from the docutils root
 DATA_ROOT = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data')
@@ -313,25 +314,6 @@
                 encoding=None)
         self.assertEqual('Grüße\n', source.read())
 
-    @unittest.skipIf(preferredencoding in (None, 'ascii', 'utf-8'),
-                     'locale encoding not set or UTF-8')
-    def test_fallback_no_utf8(self):
-        # If  no encoding is given and decoding with 'utf-8' fails,
-        # use the locale's preferred encoding (if not None).
-        # Provisional: the default will become 'utf-8'
-        # (without auto-detection and fallback) in Docutils 0.22.
-        with warnings.catch_warnings():
-            if SUPPRESS_ENCODING_WARNING:
-                warnings.filterwarnings('ignore', category=EncodingWarning)
-            source = du_io.FileInput(
-                source_path=os.path.join(DATA_ROOT, 'latin1.txt'),
-                encoding=None)
-        data = source.read()
-        successful_encoding = codecs.lookup(source.successful_encoding).name
-        self.assertEqual(preferredencoding, successful_encoding)
-        if successful_encoding == 'iso8859-1':
-            self.assertEqual('Grüße\n', data)
-
     def test_readlines(self):
         source = du_io.FileInput(
             source_path=os.path.join(DATA_ROOT, 'include.txt'))

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



_______________________________________________
Docutils-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/docutils-checkins
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.