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

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

Issue 16510: Using appropriate checks in tests
Patch Set: Created 7 years, 4 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
« no previous file with comments | « Lib/test/test_fnmatch.py ('k') | Lib/test/test_funcattrs.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Test script for ftplib module.""" 1 """Test script for ftplib module."""
2 2
3 # Modified by Giampaolo Rodola' to test FTP class, IPv6 and TLS 3 # Modified by Giampaolo Rodola' to test FTP class, IPv6 and TLS
4 # environment 4 # environment
5 5
6 import ftplib 6 import ftplib
7 import asyncore 7 import asyncore
8 import asynchat 8 import asynchat
9 import socket 9 import socket
10 import io 10 import io
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 # (2) Signal the caller that it is safe to close the socket. 925 # (2) Signal the caller that it is safe to close the socket.
926 evt.set() 926 evt.set()
927 conn.close() 927 conn.close()
928 finally: 928 finally:
929 serv.close() 929 serv.close()
930 # (3) Signal the caller that we are done. 930 # (3) Signal the caller that we are done.
931 evt.set() 931 evt.set()
932 932
933 def testTimeoutDefault(self): 933 def testTimeoutDefault(self):
934 # default -- use global socket timeout 934 # default -- use global socket timeout
935 self.assertTrue(socket.getdefaulttimeout() is None) 935 self.assertIsNone(socket.getdefaulttimeout())
936 socket.setdefaulttimeout(30) 936 socket.setdefaulttimeout(30)
937 try: 937 try:
938 ftp = ftplib.FTP("localhost") 938 ftp = ftplib.FTP("localhost")
939 finally: 939 finally:
940 socket.setdefaulttimeout(None) 940 socket.setdefaulttimeout(None)
941 self.assertEqual(ftp.sock.gettimeout(), 30) 941 self.assertEqual(ftp.sock.gettimeout(), 30)
942 self.evt.wait() 942 self.evt.wait()
943 ftp.close() 943 ftp.close()
944 944
945 def testTimeoutNone(self): 945 def testTimeoutNone(self):
946 # no timeout -- do not use global socket timeout 946 # no timeout -- do not use global socket timeout
947 self.assertTrue(socket.getdefaulttimeout() is None) 947 self.assertIsNone(socket.getdefaulttimeout())
948 socket.setdefaulttimeout(30) 948 socket.setdefaulttimeout(30)
949 try: 949 try:
950 ftp = ftplib.FTP("localhost", timeout=None) 950 ftp = ftplib.FTP("localhost", timeout=None)
951 finally: 951 finally:
952 socket.setdefaulttimeout(None) 952 socket.setdefaulttimeout(None)
953 self.assertTrue(ftp.sock.gettimeout() is None) 953 self.assertIsNone(ftp.sock.gettimeout())
954 self.evt.wait() 954 self.evt.wait()
955 ftp.close() 955 ftp.close()
956 956
957 def testTimeoutValue(self): 957 def testTimeoutValue(self):
958 # a value 958 # a value
959 ftp = ftplib.FTP(HOST, timeout=30) 959 ftp = ftplib.FTP(HOST, timeout=30)
960 self.assertEqual(ftp.sock.gettimeout(), 30) 960 self.assertEqual(ftp.sock.gettimeout(), 30)
961 self.evt.wait() 961 self.evt.wait()
962 ftp.close() 962 ftp.close()
963 963
(...skipping 30 matching lines...) Expand all
994 994
995 thread_info = support.threading_setup() 995 thread_info = support.threading_setup()
996 try: 996 try:
997 support.run_unittest(*tests) 997 support.run_unittest(*tests)
998 finally: 998 finally:
999 support.threading_cleanup(*thread_info) 999 support.threading_cleanup(*thread_info)
1000 1000
1001 1001
1002 if __name__ == '__main__': 1002 if __name__ == '__main__':
1003 test_main() 1003 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_fnmatch.py ('k') | Lib/test/test_funcattrs.py » ('j') | no next file with comments »

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