[3.15] Test that `ValueError` is raised when `vfsopen` is passed an invalid mode (GH-154008) (#154064)

tomasr8 <[email protected]>
Newsgroups gmane.comp.python.cvs
Message-ID <[email protected]>
https://github.com/python/cpython/commit/003764f671893bb7d3233ffde3f140032ba3f79d
commit: 003764f671893bb7d3233ffde3f140032ba3f79d
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: tomasr8 <[email protected]>
date: 2026-07-19T09:10:16Z
summary:

[3.15] Test that `ValueError` is raised when `vfsopen` is passed an invalid mode (GH-154008) (#154064)

Test that `ValueError` is raised when `vfsopen` is passed an invalid mode (GH-154008)

* ValueError with message test

* Remove white space

* Apply suggestions from code review

Change from double quotes to single quotes.



---------
(cherry picked from commit 9f5af278960a2f73a2e070de5141701e72675cf6)

Co-authored-by: Rayan <[email protected]>
Co-authored-by: Tomas R. <[email protected]>

files:
M Lib/test/test_pathlib/test_read.py

diff --git a/Lib/test/test_pathlib/test_read.py b/Lib/test/test_pathlib/test_read.py
index 16fb555b2aee05..51eede9d9ebafb 100644
--- a/Lib/test/test_pathlib/test_read.py
+++ b/Lib/test/test_pathlib/test_read.py
@@ -329,6 +329,11 @@ def test_info_is_symlink(self):
         self.assertFalse((p / 'fileA\udfff').info.is_symlink())
         self.assertFalse((p / 'fileA\x00').info.is_symlink())
 
+    def test_invalid_mode(self):
+        p = self.root / 'fileA'
+        with self.assertRaisesRegex(ValueError, 'invalid mode'):
+            vfsopen(p, 'q')
+
 
 class ZipPathReadTest(ReadTestBase, unittest.TestCase):
     ground = ZipPathGround(ReadableZipPath)

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
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.