Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(158030)

Side by Side Diff: Lib/test/test_ssl.py

Issue 23001: Accept mutable bytes-like objects
Patch Set: Created 4 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Test the support for SSL and sockets 1 # Test the support for SSL and sockets
2 2
3 import sys 3 import sys
4 import unittest 4 import unittest
5 from test import support 5 from test import support
6 import socket 6 import socket
7 import select 7 import select
8 import time 8 import time
9 import datetime 9 import datetime
10 import gc 10 import gc
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 self.assertRaises(ssl.SSLError, ssl.RAND_bytes, 16) 164 self.assertRaises(ssl.SSLError, ssl.RAND_bytes, 16)
165 165
166 # negative num is invalid 166 # negative num is invalid
167 self.assertRaises(ValueError, ssl.RAND_bytes, -5) 167 self.assertRaises(ValueError, ssl.RAND_bytes, -5)
168 self.assertRaises(ValueError, ssl.RAND_pseudo_bytes, -5) 168 self.assertRaises(ValueError, ssl.RAND_pseudo_bytes, -5)
169 169
170 if hasattr(ssl, 'RAND_egd'): 170 if hasattr(ssl, 'RAND_egd'):
171 self.assertRaises(TypeError, ssl.RAND_egd, 1) 171 self.assertRaises(TypeError, ssl.RAND_egd, 1)
172 self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1) 172 self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1)
173 ssl.RAND_add("this is a random string", 75.0) 173 ssl.RAND_add("this is a random string", 75.0)
174 ssl.RAND_add(b"this is a random bytes object", 75.0)
175 ssl.RAND_add(bytearray(b"this is a random bytearray object"), 75.0)
174 176
175 @unittest.skipUnless(os.name == 'posix', 'requires posix') 177 @unittest.skipUnless(os.name == 'posix', 'requires posix')
176 def test_random_fork(self): 178 def test_random_fork(self):
177 status = ssl.RAND_status() 179 status = ssl.RAND_status()
178 if not status: 180 if not status:
179 self.fail("OpenSSL's PRNG has insufficient randomness") 181 self.fail("OpenSSL's PRNG has insufficient randomness")
180 182
181 rfd, wfd = os.pipe() 183 rfd, wfd = os.pipe()
182 pid = os.fork() 184 pid = os.fork()
183 if pid == 0: 185 if pid == 0:
(...skipping 3150 matching lines...) Expand 10 before | Expand all | Expand 10 after
3334 tests.append(ThreadedTests) 3336 tests.append(ThreadedTests)
3335 3337
3336 try: 3338 try:
3337 support.run_unittest(*tests) 3339 support.run_unittest(*tests)
3338 finally: 3340 finally:
3339 if _have_threads: 3341 if _have_threads:
3340 support.threading_cleanup(*thread_info) 3342 support.threading_cleanup(*thread_info)
3341 3343
3342 if __name__ == "__main__": 3344 if __name__ == "__main__":
3343 test_main() 3345 test_main()
OLDNEW

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+