]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Test that `ValueError` is raised when `vfsopen` is passed an invalid mode (#154008)
authorRayan <157278782+ravg998@users.noreply.github.com>
Sun, 19 Jul 2026 08:21:26 +0000 (10:21 +0200)
committerGitHub <noreply@github.com>
Sun, 19 Jul 2026 08:21:26 +0000 (08:21 +0000)
* ValueError with message test

* Remove white space

* Apply suggestions from code review

Change from double quotes to single quotes.

Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
---------

Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Lib/test/test_pathlib/test_read.py

index 16fb555b2aee0517b73608a13d5b3cd9dae0de02..51eede9d9ebafb84176c242a5c7c6b630571d8bf 100644 (file)
@@ -329,6 +329,11 @@ class ReadTestBase:
         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)