summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_io.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2019-10-28 14:40:08 (GMT)
committerGitHub <noreply@github.com>2019-10-28 14:40:08 (GMT)
commite471e72977c83664f13d041c78549140c86c92de (patch)
treefeddc2c15e7199122f6f59992de0dab8f73b6149 /Lib/test/test_io.py
parent3bfc8e0fcc707d200c267ff05b052fd6a63c985a (diff)
downloadcpython-e471e72977c83664f13d041c78549140c86c92de.zip
cpython-e471e72977c83664f13d041c78549140c86c92de.tar.gz
cpython-e471e72977c83664f13d041c78549140c86c92de.tar.bz2
bpo-37330: open() no longer accept 'U' in file mode (GH-16959)
open(), io.open(), codecs.open() and fileinput.FileInput no longer accept "U" ("universal newline") in the file mode. This flag was deprecated since Python 3.3.
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r--Lib/test/test_io.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 1fe1cba..ad22dfe 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -3886,16 +3886,6 @@ class MiscIOTest(unittest.TestCase):
self.assertEqual(f.mode, "wb")
f.close()
- with support.check_warnings(('', DeprecationWarning)):
- f = self.open(support.TESTFN, "U")
- self.assertEqual(f.name, support.TESTFN)
- self.assertEqual(f.buffer.name, support.TESTFN)
- self.assertEqual(f.buffer.raw.name, support.TESTFN)
- self.assertEqual(f.mode, "U")
- self.assertEqual(f.buffer.mode, "rb")
- self.assertEqual(f.buffer.raw.mode, "rb")
- f.close()
-
f = self.open(support.TESTFN, "w+")
self.assertEqual(f.mode, "w+")
self.assertEqual(f.buffer.mode, "rb+") # Does it really matter?
@@ -3909,6 +3899,13 @@ class MiscIOTest(unittest.TestCase):
f.close()
g.close()
+ def test_removed_u_mode(self):
+ # "U" mode has been removed in Python 3.9
+ for mode in ("U", "rU", "r+U"):
+ with self.assertRaises(ValueError) as cm:
+ self.open(support.TESTFN, mode)
+ self.assertIn('invalid mode', str(cm.exception))
+
def test_io_after_close(self):
for kwargs in [
{"mode": "w"},