[Python-checkins] bpo-44949: Fix test_readline auto history tests (GH-27813) (GH-31118)

ambv webhook-mailer at python.org
Thu Feb 17 03:32:13 EST 2022


https://github.com/python/cpython/commit/b1bc04df817ecb3fb9fdbefa3782efea54488e6f
commit: b1bc04df817ecb3fb9fdbefa3782efea54488e6f
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: ambv <lukasz at langa.pl>
date: 2022-02-17T09:32:03+01:00
summary:

bpo-44949: Fix test_readline auto history tests (GH-27813) (GH-31118)

(cherry picked from commit 6fb62b42f4db56ed5efe0ca4c1059049276c1083)

Co-authored-by: Victor Stinner <vstinner at python.org>

files:
A Misc/NEWS.d/next/Tests/2021-08-18-18-30-12.bpo-44949.VE5ENv.rst
M Lib/test/test_readline.py

diff --git a/Lib/test/test_readline.py b/Lib/test/test_readline.py
index 3574657cf3635..6bde9e3c59806 100644
--- a/Lib/test/test_readline.py
+++ b/Lib/test/test_readline.py
@@ -147,11 +147,15 @@ def test_init(self):
 
     def test_auto_history_enabled(self):
         output = run_pty(self.auto_history_script.format(True))
-        self.assertIn(b"History length: 1\r\n", output)
+        # bpo-44949: Sometimes, the newline character is not written at the
+        # end, so don't expect it in the output.
+        self.assertIn(b"History length: 1", output)
 
     def test_auto_history_disabled(self):
         output = run_pty(self.auto_history_script.format(False))
-        self.assertIn(b"History length: 0\r\n", output)
+        # bpo-44949: Sometimes, the newline character is not written at the
+        # end, so don't expect it in the output.
+        self.assertIn(b"History length: 0", output)
 
     def test_nonascii(self):
         loc = locale.setlocale(locale.LC_CTYPE, None)
diff --git a/Misc/NEWS.d/next/Tests/2021-08-18-18-30-12.bpo-44949.VE5ENv.rst b/Misc/NEWS.d/next/Tests/2021-08-18-18-30-12.bpo-44949.VE5ENv.rst
new file mode 100644
index 0000000000000..7fdf1810b165e
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2021-08-18-18-30-12.bpo-44949.VE5ENv.rst
@@ -0,0 +1,2 @@
+Fix auto history tests of test_readline: sometimes, the newline character is
+not written at the end, so don't expect it in the output.



More information about the Python-checkins mailing list