oldhandler = signal.signal(signal.SIGXFSZ, signal.SIG_IGN) except (ImportError, AttributeError): pass # create >2GB file (2GB = 2147483648 bytes) size = 2500000000L name = test_support.TESTFN # On Windows and Mac OSX this test comsumes large resources; It takes # a long time to build the >2GB file and takes >2GB of disk space # therefore the resource must be enabled to run this test. If not, # nothing after this line stanza will be executed. if sys.platform[:3] == "win" or sys.platform == "darwin": test_support.requires("largefile", "test requires %s bytes and a long time to run" % str(size)) else: # Only run if the current filesystem supports large files. # (Skip this test on Windows, since we now always support large files.) f = open(test_support.TESTFN, "wb") try: # 2**31 == 2147483648 f.seek(2147483649L) # Seeking is not enough of a test: you must write and flush, too! f.write("x") f.flush() except (IOError, OverflowError): f.close() os.unlink(test_support.TESTFN) raise test_support.TestSkipped, "filesystem does not have largefile support" else:
except (ImportError, AttributeError): pass # create >2GB file (2GB = 2147483648 bytes) size = 2500000000L name = test_support.TESTFN # On Windows this test comsumes large resources; It takes a long time to build # the >2GB file and takes >2GB of disk space therefore the resource must be # enabled to run this test. If not, nothing after this line stanza will be # executed. if sys.platform[:3] == 'win': test_support.requires( 'largefile', 'test requires %s bytes and a long time to run' % str(size)) else: # Only run if the current filesystem supports large files. # (Skip this test on Windows, since we now always support large files.) f = open(test_support.TESTFN, 'wb') try: # 2**31 == 2147483648 f.seek(2147483649L) # Seeking is not enough of a test: you must write and flush, too! f.write("x") f.flush() except (IOError, OverflowError): f.close() os.unlink(test_support.TESTFN) raise test_support.TestSkipped, \
# limit will raise IOError instead of crashing the interpreter. oldhandler = signal.signal(signal.SIGXFSZ, signal.SIG_IGN) except (ImportError, AttributeError): pass # create >2GB file (2GB = 2147483648 bytes) size = 2500000000L name = test_support.TESTFN # On Windows and Mac OSX this test comsumes large resources; It takes # a long time to build the >2GB file and takes >2GB of disk space # therefore the resource must be enabled to run this test. If not, # nothing after this line stanza will be executed. if sys.platform[:3] == 'win' or sys.platform == 'darwin': test_support.requires( 'largefile', 'test requires %s bytes and a long time to run' % str(size)) else: # Only run if the current filesystem supports large files. # (Skip this test on Windows, since we now always support large files.) f = open(test_support.TESTFN, 'wb') try: # 2**31 == 2147483648 f.seek(2147483649L) # Seeking is not enough of a test: you must write and flush, too! f.write("x") f.flush() except (IOError, OverflowError): f.close() os.unlink(test_support.TESTFN) raise test_support.TestSkipped, \
# Test suite for SocketServer.py import test_support from test_support import verbose, verify, TESTFN, TestSkipped test_support.requires('network') from SocketServer import * import socket import select import time import threading import os NREQ = 3 DELAY = 0.5 class MyMixinHandler: def handle(self): time.sleep(DELAY) line = self.rfile.readline() time.sleep(DELAY) self.wfile.write(line) class MyStreamHandler(MyMixinHandler, StreamRequestHandler): pass class MyDatagramHandler(MyMixinHandler, DatagramRequestHandler): pass class MyMixinServer: def serve_a_few(self): for i in range(NREQ): self.handle_request()
# Test just the SSL support in the socket module, in a moderately bogus way. import test_support # Optionally test SSL support. This currently requires the 'network' resource # as given on the regrtest command line. If not available, nothing after this # line will be executed. test_support.requires('network') import socket if not hasattr(socket, "ssl"): raise test_support.TestSkipped("socket module has no ssl support") import urllib socket.RAND_status() try: socket.RAND_egd(1) except TypeError: pass else: print "didn't raise TypeError" socket.RAND_add("this is a random string", 75.0) f = urllib.urlopen('https://sf.net') buf = f.read() f.close()
# Test suite for SocketServer.py import test_support from test_support import verbose, verify, TESTFN, TestSkipped test_support.requires('network') from SocketServer import * import socket import select import time import threading import os NREQ = 3 DELAY = 0.5 class MyMixinHandler: def handle(self): time.sleep(DELAY) line = self.rfile.readline() time.sleep(DELAY) self.wfile.write(line) class MyStreamHandler(MyMixinHandler, StreamRequestHandler): pass class MyDatagramHandler(MyMixinHandler, DatagramRequestHandler): pass class MyMixinServer: def serve_a_few(self): for i in range(NREQ): self.handle_request() def handle_error(self, request, client_address): self.close_request(request) self.server_close() raise
# # This script doesn't actually display anything very coherent. but it # does call every method and function. # # Functions not tested: {def,reset}_{shell,prog}_mode, getch(), getstr(), # getmouse(), ungetmouse(), init_color() # import curses, sys, tempfile # Optionally test curses module. This currently requires that the # 'curses' resource be given on the regrtest command line using the -u # option. If not available, nothing after this line will be executed. import test_support test_support.requires('curses') def window_funcs(stdscr): "Test the methods of windows" win = curses.newwin(10,10) win = curses.newwin(5,5, 5,5) win2 = curses.newwin(15,15, 5,5) for meth in [stdscr.addch, stdscr.addstr]: for args in [('a'), ('a', curses.A_BOLD), (4,4, 'a'), (5,5, 'a', curses.A_BOLD)]: apply(meth, args) for meth in [stdscr.box, stdscr.clear, stdscr.clrtobot, stdscr.clrtoeol, stdscr.cursyncup, stdscr.delch, stdscr.deleteln, stdscr.erase, stdscr.getbegyx,
#!python #---------------------------------------------------------------------- # test largefile support on system where this makes sense # #---------------------------------------------------------------------- import test_support import os, struct, stat, sys try: import signal # The default handler for SIGXFSZ is to abort the process. # By ignoring it, system calls exceeding the file size resource # limit will raise IOError instead of crashing the interpreter. oldhandler = signal.signal(signal.SIGXFSZ, signal.SIG_IGN) except (ImportError, AttributeError): pass # create >2GB file (2GB = 2147483648 bytes) size = 2500000000L name = test_support.TESTFN # On Windows this test comsumes large resources; It takes a long time to build # the >2GB file and takes >2GB of disk space therefore the resource must be # enabled to run this test. If not, nothing after this line stanza will be # executed. if sys.platform[:3] == 'win': test_support.requires( 'largefile', 'test requires %s bytes and a long time to run' % str(size)) else: # Only run if the current filesystem supports large files.
# # Test script for the curses module # # This script doesn't actually display anything very coherent. but it # does call every method and function. # # Functions not tested: {def,reset}_{shell,prog}_mode, getch(), getstr(), # getmouse(), ungetmouse(), init_color() # import curses, sys, tempfile # Optionally test curses module. This currently requires that the # 'curses' resource be given on the regrtest command line using the -u # option. If not available, nothing after this line will be executed. import test_support test_support.requires('curses') def window_funcs(stdscr): "Test the methods of windows" win = curses.newwin(10,10) win = curses.newwin(5,5, 5,5) win2 = curses.newwin(15,15, 5,5) for meth in [stdscr.addch, stdscr.addstr]: for args in [('a'), ('a', curses.A_BOLD), (4,4, 'a'), (5,5, 'a', curses.A_BOLD)]: apply(meth, args) for meth in [stdscr.box, stdscr.clear, stdscr.clrtobot, stdscr.clrtoeol, stdscr.cursyncup, stdscr.delch, stdscr.deleteln, stdscr.erase, stdscr.getbegyx, stdscr.getbkgd, stdscr.getkey, stdscr.getmaxyx, stdscr.getparyx, stdscr.getyx, stdscr.inch, stdscr.insertln, stdscr.instr, stdscr.is_wintouched,
# # This script doesn't actually display anything very coherent. but it # does call every method and function. # # Functions not tested: {def,reset}_{shell,prog}_mode, getch(), getstr(), # getmouse(), ungetmouse(), init_color() # import curses, sys, tempfile # Optionally test curses module. This currently requires that the # 'curses' resource be given on the regrtest command line using the -u # option. If not available, nothing after this line will be executed. import test_support test_support.requires('curses') def window_funcs(stdscr): "Test the methods of windows" win = curses.newwin(10, 10) win = curses.newwin(5, 5, 5, 5) win2 = curses.newwin(15, 15, 5, 5) for meth in [stdscr.addch, stdscr.addstr]: for args in [('a'), ('a', curses.A_BOLD), (4, 4, 'a'), (5, 5, 'a', curses.A_BOLD)]: apply(meth, args) for meth in [ stdscr.box, stdscr.clear, stdscr.clrtobot, stdscr.clrtoeol,
# # Test script for the curses module # # This script doesn't actually display anything very coherent. but it # does call every method and function. # # Functions not tested: {def,reset}_{shell,prog}_mode, getch(), getstr(), # getmouse(), ungetmouse(), init_color() # import curses, sys, tempfile # Optionally test curses module. This currently requires that the # 'curses' resource be given on the regrtest command line using the -u # option. If not available, nothing after this line will be executed. import test_support test_support.requires('curses') def window_funcs(stdscr): "Test the methods of windows" win = curses.newwin(10, 10) win = curses.newwin(5, 5, 5, 5) win2 = curses.newwin(15, 15, 5, 5) for meth in [stdscr.addch, stdscr.addstr]: for args in [('a'), ('a', curses.A_BOLD), (4, 4, 'a'), (5, 5, 'a', curses.A_BOLD)]: apply(meth, args) for meth in [ stdscr.box, stdscr.clear, stdscr.clrtobot, stdscr.clrtoeol, stdscr.cursyncup, stdscr.delch, stdscr.deleteln, stdscr.erase, stdscr.getbegyx, stdscr.getbkgd, stdscr.getkey, stdscr.getmaxyx, stdscr.getparyx, stdscr.getyx, stdscr.inch, stdscr.insertln,