From 6ce21062ad5b8a8bdcdea97ff3fd9227f4820166 Mon Sep 17 00:00:00 2001 From: milde Date: Wed, 31 May 2017 21:34:55 +0000 Subject: [PATCH] Fix [ 318 ] false positive in test_heuristics_no_utf8. The heuristics is skipped under Py3k unless decoding with locale encoding fails. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@8098 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- test/test_io.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/test_io.py b/test/test_io.py index abaee6c45..003203137 100755 --- a/test/test_io.py +++ b/test/test_io.py @@ -111,11 +111,18 @@ print "hello world" def test_heuristics_no_utf8(self): # if no encoding is given and decoding with utf8 fails, - # use either the locale encoding (if specified) or latin1: + # use either the locale encoding (if specified) or latin-1: + if sys.version_info >= (3,0) and locale_encoding != "utf8": + # in Py3k, the locale encoding is used without --input-encoding + # skipping the heuristic unless decoding fails. + return + probed_encodings = (locale_encoding, 'latin-1') input = io.FileInput(source_path='data/latin1.txt') data = input.read() - self.assertTrue(input.successful_encoding in (locale_encoding, - 'latin-1')) + if input.successful_encoding not in probed_encodings: + raise AssertionError( + "guessed encoding '%s' differs from probed encodings %r" + % (input.successful_encoding, probed_encodings)) if input.successful_encoding == 'latin-1': self.assertEqual(data, u'Gr\xfc\xdfe\n') -- 2.11.4.GIT