mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Issue #16915: Clarify that mode parameter of socket.makefile() does not accept
the same values as open().
This commit is contained in:
commit
31a252b7f3
3 changed files with 19 additions and 4 deletions
|
@ -1374,6 +1374,20 @@ class GeneralModuleTests(unittest.TestCase):
|
|||
self.assertRaises(ValueError, fp.writable)
|
||||
self.assertRaises(ValueError, fp.seekable)
|
||||
|
||||
def test_makefile_mode(self):
|
||||
for mode in 'r', 'rb', 'rw', 'w', 'wb':
|
||||
with self.subTest(mode=mode):
|
||||
with socket.socket() as sock:
|
||||
with sock.makefile(mode) as fp:
|
||||
self.assertEqual(fp.mode, mode)
|
||||
|
||||
def test_makefile_invalid_mode(self):
|
||||
for mode in 'rt', 'x', '+', 'a':
|
||||
with self.subTest(mode=mode):
|
||||
with socket.socket() as sock:
|
||||
with self.assertRaisesRegex(ValueError, 'invalid mode'):
|
||||
sock.makefile(mode)
|
||||
|
||||
def test_pickle(self):
|
||||
sock = socket.socket()
|
||||
with sock:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue