diff options
author | Guido van Rossum <guido@python.org> | 2007-05-11 16:50:42 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-05-11 16:50:42 (GMT) |
commit | 0368b726a1859e3c063df5a93f19ccb4254be22a (patch) | |
tree | 4e65a593d48f9103facb47b741f8ed97d755286f /Lib | |
parent | bdde01168fc91d02a2d3bc8399255944fdfdd69f (diff) | |
download | cpython-0368b726a1859e3c063df5a93f19ccb4254be22a.zip cpython-0368b726a1859e3c063df5a93f19ccb4254be22a.tar.gz cpython-0368b726a1859e3c063df5a93f19ccb4254be22a.tar.bz2 |
Merged revisions 55225-55227,55229-55269 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
................
r55238 | guido.van.rossum | 2007-05-10 16:46:05 -0700 (Thu, 10 May 2007) | 9 lines
Merged revisions 55227 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r55227 | guido.van.rossum | 2007-05-10 10:20:15 -0700 (Thu, 10 May 2007) | 2 lines
Fix a bug in test_c_api() that caused a negative refcount.
........
................
r55246 | neal.norwitz | 2007-05-11 00:01:52 -0700 (Fri, 11 May 2007) | 1 line
Remove commands.getstatus() it is obsolete.
................
r55248 | neal.norwitz | 2007-05-11 00:29:05 -0700 (Fri, 11 May 2007) | 2 lines
Remove bsddb185 support.
................
r55249 | neal.norwitz | 2007-05-11 00:29:50 -0700 (Fri, 11 May 2007) | 1 line
Remove bsddb185 module too
................
r55250 | neal.norwitz | 2007-05-11 00:32:13 -0700 (Fri, 11 May 2007) | 1 line
bsddb185: Gotta remove from the file checked in, not Setup
................
r55251 | neal.norwitz | 2007-05-11 00:53:26 -0700 (Fri, 11 May 2007) | 1 line
Remove obsolete IRIX modules (as much as I could find, there is probably more)
................
r55252 | neal.norwitz | 2007-05-11 00:55:35 -0700 (Fri, 11 May 2007) | 1 line
Remove SGI turd.
................
r55254 | georg.brandl | 2007-05-11 03:11:01 -0700 (Fri, 11 May 2007) | 2 lines
Add a case for set comprehensions to the "cannot assign to" switch.
................
r55255 | georg.brandl | 2007-05-11 03:11:25 -0700 (Fri, 11 May 2007) | 2 lines
Fix wrong imports.
................
r55261 | georg.brandl | 2007-05-11 07:37:48 -0700 (Fri, 11 May 2007) | 2 lines
Remove removed tex files.
................
r55262 | georg.brandl | 2007-05-11 08:28:41 -0700 (Fri, 11 May 2007) | 2 lines
Commit PEP 3132 implementation.
................
r55264 | georg.brandl | 2007-05-11 08:50:19 -0700 (Fri, 11 May 2007) | 2 lines
Check in the inevitable AST version number and format Py_ssize_t with %zd.
................
r55265 | neal.norwitz | 2007-05-11 09:12:22 -0700 (Fri, 11 May 2007) | 1 line
Remove mention of os.popen* and popen2.* since these will be removed.
................
r55266 | neal.norwitz | 2007-05-11 09:19:57 -0700 (Fri, 11 May 2007) | 1 line
Get doc to build again (almost, the doc is fine)
................
r55267 | neal.norwitz | 2007-05-11 09:21:02 -0700 (Fri, 11 May 2007) | 1 line
Really get doc to build (remove use of string module)
................
r55269 | neal.norwitz | 2007-05-11 09:29:43 -0700 (Fri, 11 May 2007) | 1 line
Add some notes to cleanup later
................
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/commands.py | 11 | ||||
-rw-r--r-- | Lib/subprocess.py | 69 | ||||
-rwxr-xr-x | Lib/test/regrtest.py | 99 | ||||
-rwxr-xr-x | Lib/test/test_al.py | 23 | ||||
-rw-r--r-- | Lib/test/test_bsddb185.py | 43 | ||||
-rwxr-xr-x | Lib/test/test_cd.py | 26 | ||||
-rwxr-xr-x | Lib/test/test_cl.py | 78 | ||||
-rw-r--r-- | Lib/test/test_commands.py | 22 | ||||
-rwxr-xr-x | Lib/test/test_gl.py | 150 | ||||
-rwxr-xr-x | Lib/test/test_imgfile.py | 116 | ||||
-rw-r--r-- | Lib/test/test_listcomps.py | 2 | ||||
-rw-r--r-- | Lib/test/test_setcomps.py | 6 | ||||
-rw-r--r-- | Lib/test/test_unpack_ex.py | 157 |
13 files changed, 162 insertions, 640 deletions
diff --git a/Lib/commands.py b/Lib/commands.py index d19aa1a..ee4db85 100644 --- a/Lib/commands.py +++ b/Lib/commands.py @@ -19,7 +19,7 @@ Encapsulates the basic operation: [Note: it would be nice to add functions to interpret the exit status.] """ -__all__ = ["getstatusoutput","getoutput","getstatus"] +__all__ = ["getstatusoutput", "getoutput"] # Module 'commands' # @@ -28,15 +28,6 @@ __all__ = ["getstatusoutput","getoutput","getstatus"] # NB This only works (and is only relevant) for UNIX. -# Get 'ls -l' status for an object into a string -# -def getstatus(file): - """Return output of "ls -ld <file>" in a string.""" - import warnings - warnings.warn("commands.getstatus() is deprecated", DeprecationWarning) - return getoutput('ls -ld' + mkarg(file)) - - # Get the output from a shell command into a string. # The exit status is ignored; a trailing newline is stripped. # Assume the command will work with '{ ... ; } 2>&1' around it.. diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 53d5db0..30c2a24 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -17,8 +17,6 @@ intends to replace several other, older modules and functions, like: os.system os.spawn* -os.popen* -popen2.* commands.* Information about how the subprocess module can be used to replace these @@ -283,73 +281,6 @@ Environment example: os.spawnlpe(os.P_NOWAIT, "/bin/mycmd", "mycmd", "myarg", env) ==> Popen(["/bin/mycmd", "myarg"], env={"PATH": "/usr/bin"}) - - -Replacing os.popen* -------------------- -pipe = os.popen(cmd, mode='r', bufsize) -==> -pipe = Popen(cmd, shell=True, bufsize=bufsize, stdout=PIPE).stdout - -pipe = os.popen(cmd, mode='w', bufsize) -==> -pipe = Popen(cmd, shell=True, bufsize=bufsize, stdin=PIPE).stdin - - -(child_stdin, child_stdout) = os.popen2(cmd, mode, bufsize) -==> -p = Popen(cmd, shell=True, bufsize=bufsize, - stdin=PIPE, stdout=PIPE, close_fds=True) -(child_stdin, child_stdout) = (p.stdin, p.stdout) - - -(child_stdin, - child_stdout, - child_stderr) = os.popen3(cmd, mode, bufsize) -==> -p = Popen(cmd, shell=True, bufsize=bufsize, - stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) -(child_stdin, - child_stdout, - child_stderr) = (p.stdin, p.stdout, p.stderr) - - -(child_stdin, child_stdout_and_stderr) = os.popen4(cmd, mode, bufsize) -==> -p = Popen(cmd, shell=True, bufsize=bufsize, - stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) -(child_stdin, child_stdout_and_stderr) = (p.stdin, p.stdout) - - -Replacing popen2.* ------------------- -Note: If the cmd argument to popen2 functions is a string, the command -is executed through /bin/sh. If it is a list, the command is directly -executed. - -(child_stdout, child_stdin) = popen2.popen2("somestring", bufsize, mode) -==> -p = Popen(["somestring"], shell=True, bufsize=bufsize - stdin=PIPE, stdout=PIPE, close_fds=True) -(child_stdout, child_stdin) = (p.stdout, p.stdin) - - -(child_stdout, child_stdin) = popen2.popen2(["mycmd", "myarg"], bufsize, mode) -==> -p = Popen(["mycmd", "myarg"], bufsize=bufsize, - stdin=PIPE, stdout=PIPE, close_fds=True) -(child_stdout, child_stdin) = (p.stdout, p.stdin) - -The popen2.Popen3 and popen3.Popen4 basically works as subprocess.Popen, -except that: - -* subprocess.Popen raises an exception if the execution fails -* the capturestderr argument is replaced with the stderr argument. -* stdin=PIPE and stdout=PIPE must be specified. -* popen2 closes all filedescriptors by default, but you have to specify - close_fds=True with subprocess.Popen. - - """ import sys diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index 331b441..7458b5e 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -818,11 +818,7 @@ _expectations = { """ test__locale test_applesingle - test_al - test_bsddb185 test_bsddb3 - test_cd - test_cl test_commands test_crypt test_curses @@ -831,9 +827,7 @@ _expectations = { test_fcntl test_fork1 test_gdbm - test_gl test_grp - test_imgfile test_ioctl test_largefile test_linuxaudiodev @@ -855,15 +849,9 @@ _expectations = { """, 'linux2': """ - test_al test_applesingle - test_bsddb185 - test_cd - test_cl test_curses test_dl - test_gl - test_imgfile test_largefile test_linuxaudiodev test_nis @@ -875,14 +863,10 @@ _expectations = { """, 'mac': """ - test_al test_atexit test_bsddb - test_bsddb185 test_bsddb3 test_bz2 - test_cd - test_cl test_commands test_crypt test_curses @@ -890,10 +874,8 @@ _expectations = { test_dl test_fcntl test_fork1 - test_gl test_grp test_ioctl - test_imgfile test_largefile test_linuxaudiodev test_locale @@ -919,15 +901,9 @@ _expectations = { """, 'unixware7': """ - test_al test_applesingle test_bsddb - test_bsddb185 - test_cd - test_cl test_dl - test_gl - test_imgfile test_largefile test_linuxaudiodev test_minidom @@ -943,15 +919,9 @@ _expectations = { """, 'openunix8': """ - test_al test_applesingle test_bsddb - test_bsddb185 - test_cd - test_cl test_dl - test_gl - test_imgfile test_largefile test_linuxaudiodev test_minidom @@ -967,18 +937,12 @@ _expectations = { """, 'sco_sv3': """ - test_al test_applesingle test_asynchat test_bsddb - test_bsddb185 - test_cd - test_cl test_dl test_fork1 test_gettext - test_gl - test_imgfile test_largefile test_linuxaudiodev test_locale @@ -1000,15 +964,11 @@ _expectations = { """, 'riscos': """ - test_al test_applesingle test_asynchat test_atexit test_bsddb - test_bsddb185 test_bsddb3 - test_cd - test_cl test_commands test_crypt test_dbm @@ -1016,9 +976,7 @@ _expectations = { test_fcntl test_fork1 test_gdbm - test_gl test_grp - test_imgfile test_largefile test_linuxaudiodev test_locale @@ -1043,12 +1001,7 @@ _expectations = { """, 'darwin': """ - test_al - test_cd - test_cl test_gdbm - test_gl - test_imgfile test_largefile test_linuxaudiodev test_locale @@ -1059,18 +1012,12 @@ _expectations = { """, 'sunos5': """ - test_al test_applesingle test_bsddb - test_bsddb185 - test_cd - test_cl test_curses test_dbm test_gdbm - test_gl test_gzip - test_imgfile test_linuxaudiodev test_openpty test_sqlite @@ -1080,18 +1027,12 @@ _expectations = { """, 'hp-ux11': """ - test_al test_applesingle test_bsddb - test_bsddb185 - test_cd - test_cl test_curses test_dl test_gdbm - test_gl test_gzip - test_imgfile test_largefile test_linuxaudiodev test_locale @@ -1109,16 +1050,10 @@ _expectations = { """, 'atheos': """ - test_al test_applesingle - test_bsddb185 - test_cd - test_cl test_curses test_dl test_gdbm - test_gl - test_imgfile test_largefile test_linuxaudiodev test_locale @@ -1134,16 +1069,10 @@ _expectations = { """, 'cygwin': """ - test_al test_applesingle - test_bsddb185 test_bsddb3 - test_cd - test_cl test_curses test_dbm - test_gl - test_imgfile test_ioctl test_largefile test_linuxaudiodev @@ -1156,18 +1085,12 @@ _expectations = { """, 'os2emx': """ - test_al test_applesingle test_audioop - test_bsddb185 test_bsddb3 - test_cd - test_cl test_commands test_curses test_dl - test_gl - test_imgfile test_largefile test_linuxaudiodev test_mhlib @@ -1185,15 +1108,10 @@ _expectations = { 'freebsd4': """ test_aepack - test_al test_applesingle test_bsddb test_bsddb3 - test_cd - test_cl test_gdbm - test_gl - test_imgfile test_linuxaudiodev test_locale test_macfs @@ -1219,19 +1137,13 @@ _expectations = { 'aix5': """ test_aepack - test_al test_applesingle test_bsddb - test_bsddb185 test_bsddb3 test_bz2 - test_cd - test_cl test_dl test_gdbm - test_gl test_gzip - test_imgfile test_linuxaudiodev test_macfs test_macostools @@ -1249,17 +1161,12 @@ _expectations = { 'openbsd3': """ test_aepack - test_al test_applesingle test_bsddb test_bsddb3 - test_cd - test_cl test_ctypes test_dl test_gdbm - test_gl - test_imgfile test_linuxaudiodev test_locale test_macfs @@ -1281,19 +1188,13 @@ _expectations = { 'netbsd3': """ test_aepack - test_al test_applesingle test_bsddb - test_bsddb185 test_bsddb3 - test_cd - test_cl test_ctypes test_curses test_dl test_gdbm - test_gl - test_imgfile test_linuxaudiodev test_locale test_macfs diff --git a/Lib/test/test_al.py b/Lib/test/test_al.py deleted file mode 100755 index e97ca65..0000000 --- a/Lib/test/test_al.py +++ /dev/null @@ -1,23 +0,0 @@ -#! /usr/bin/env python -"""Whimpy test script for the al module - Roger E. Masse -""" -import al -from test.test_support import verbose - -alattrs = ['__doc__', '__name__', 'getdefault', 'getminmax', 'getname', 'getparams', - 'newconfig', 'openport', 'queryparams', 'setparams'] - -# This is a very unobtrusive test for the existence of the al module and all its -# attributes. More comprehensive examples can be found in Demo/al - -def main(): - # touch all the attributes of al without doing anything - if verbose: - print('Touching al module attributes...') - for attr in alattrs: - if verbose: - print('touching: ', attr) - getattr(al, attr) - -main() diff --git a/Lib/test/test_bsddb185.py b/Lib/test/test_bsddb185.py deleted file mode 100644 index df1ece0..0000000 --- a/Lib/test/test_bsddb185.py +++ /dev/null @@ -1,43 +0,0 @@ -"""Tests for the bsddb185 module. - -The file 185test.db found in Lib/test/ is for testing purposes with this -testing suite. - -""" -from test.test_support import verbose, run_unittest, findfile -import unittest -import bsddb185 -import anydbm -import whichdb -import os -import tempfile -import shutil - -class Bsddb185Tests(unittest.TestCase): - - def test_open_existing_hash(self): - # Verify we can open a file known to be a hash v2 file - db = bsddb185.hashopen(findfile("185test.db")) - self.assertEqual(db["1"], "1") - db.close() - - def test_whichdb(self): - # Verify that whichdb correctly sniffs the known hash v2 file - self.assertEqual(whichdb.whichdb(findfile("185test.db")), "bsddb185") - - def test_anydbm_create(self): - # Verify that anydbm.open does *not* create a bsddb185 file - tmpdir = tempfile.mkdtemp() - try: - dbfile = os.path.join(tmpdir, "foo.db") - anydbm.open(dbfile, "c").close() - ftype = whichdb.whichdb(dbfile) - self.assertNotEqual(ftype, "bsddb185") - finally: - shutil.rmtree(tmpdir) - -def test_main(): - run_unittest(Bsddb185Tests) - -if __name__ == "__main__": - test_main() diff --git a/Lib/test/test_cd.py b/Lib/test/test_cd.py deleted file mode 100755 index 217b38b..0000000 --- a/Lib/test/test_cd.py +++ /dev/null @@ -1,26 +0,0 @@ -#! /usr/bin/env python -"""Whimpy test script for the cd module - Roger E. Masse -""" -import cd -from test.test_support import verbose - -cdattrs = ['BLOCKSIZE', 'CDROM', 'DATASIZE', 'ERROR', 'NODISC', 'PAUSED', 'PLAYING', 'READY', - 'STILL', '__doc__', '__name__', 'atime', 'audio', 'catalog', 'control', 'createparser', 'error', - 'ident', 'index', 'msftoframe', 'open', 'pnum', 'ptime'] - - -# This is a very inobtrusive test for the existence of the cd module and all its -# attributes. More comprehensive examples can be found in Demo/cd and -# require that you have a CD and a CD ROM drive - -def main(): - # touch all the attributes of cd without doing anything - if verbose: - print('Touching cd module attributes...') - for attr in cdattrs: - if verbose: - print('touching: ', attr) - getattr(cd, attr) - -main() diff --git a/Lib/test/test_cl.py b/Lib/test/test_cl.py deleted file mode 100755 index 0df7f6f..0000000 --- a/Lib/test/test_cl.py +++ /dev/null @@ -1,78 +0,0 @@ -#! /usr/bin/env python -"""Whimpy test script for the cl module - Roger E. Masse -""" -import cl -from test.test_support import verbose - -clattrs = ['ADDED_ALGORITHM_ERROR', 'ALAW', 'ALGORITHM_ID', -'ALGORITHM_VERSION', 'AUDIO', 'AWARE_ERROR', 'AWARE_MPEG_AUDIO', -'AWARE_MULTIRATE', 'AWCMP_CONST_QUAL', 'AWCMP_FIXED_RATE', -'AWCMP_INDEPENDENT', 'AWCMP_JOINT_STEREO', 'AWCMP_LOSSLESS', -'AWCMP_MPEG_LAYER_I', 'AWCMP_MPEG_LAYER_II', 'AWCMP_STEREO', -'Algorithm', 'AlgorithmNumber', 'AlgorithmType', 'AudioFormatName', -'BAD_ALGORITHM_NAME', 'BAD_ALGORITHM_TYPE', 'BAD_BLOCK_SIZE', -'BAD_BOARD', 'BAD_BUFFERING', 'BAD_BUFFERLENGTH_NEG', -'BAD_BUFFERLENGTH_ODD', 'BAD_BUFFER_EXISTS', 'BAD_BUFFER_HANDLE', -'BAD_BUFFER_POINTER', 'BAD_BUFFER_QUERY_SIZE', 'BAD_BUFFER_SIZE', -'BAD_BUFFER_SIZE_POINTER', 'BAD_BUFFER_TYPE', -'BAD_COMPRESSION_SCHEME', 'BAD_COMPRESSOR_HANDLE', -'BAD_COMPRESSOR_HANDLE_POINTER', 'BAD_FRAME_SIZE', -'BAD_FUNCTIONALITY', 'BAD_FUNCTION_POINTER', 'BAD_HEADER_SIZE', -'BAD_INITIAL_VALUE', 'BAD_INTERNAL_FORMAT', 'BAD_LICENSE', -'BAD_MIN_GT_MAX', 'BAD_NO_BUFFERSPACE', 'BAD_NUMBER_OF_BLOCKS', -'BAD_PARAM', 'BAD_PARAM_ID_POINTER', 'BAD_PARAM_TYPE', 'BAD_POINTER', -'BAD_PVBUFFER', 'BAD_SCHEME_POINTER', 'BAD_STREAM_HEADER', -'BAD_STRING_POINTER', 'BAD_TEXT_STRING_PTR', 'BEST_FIT', -'BIDIRECTIONAL', 'BITRATE_POLICY', 'BITRATE_TARGET', -'BITS_PER_COMPONENT', 'BLENDING', 'BLOCK_SIZE', 'BOTTOM_UP', -'BUFFER_NOT_CREATED', 'BUF_DATA', 'BUF_FRAME', 'BytesPerPixel', -'BytesPerSample', 'CHANNEL_POLICY', 'CHROMA_THRESHOLD', 'CODEC', -'COMPONENTS', 'COMPRESSED_BUFFER_SIZE', 'COMPRESSION_RATIO', -'COMPRESSOR', 'CONTINUOUS_BLOCK', 'CONTINUOUS_NONBLOCK', -'CompressImage', 'DATA', 'DECOMPRESSOR', 'DecompressImage', -'EDGE_THRESHOLD', 'ENABLE_IMAGEINFO', 'END_OF_SEQUENCE', 'ENUM_VALUE', -'EXACT_COMPRESSION_RATIO', 'EXTERNAL_DEVICE', 'FLOATING_ENUM_VALUE', -'FLOATING_RANGE_VALUE', 'FRAME', 'FRAME_BUFFER_SIZE', -'FRAME_BUFFER_SIZE_ZERO', 'FRAME_RATE', 'FRAME_TYPE', 'G711_ALAW', -'G711_ULAW', 'GRAYSCALE', 'GetAlgorithmName', 'HDCC', -'HDCC_SAMPLES_PER_TILE', 'HDCC_TILE_THRESHOLD', 'HEADER_START_CODE', -'IMAGE_HEIGHT', 'IMAGE_WIDTH', 'INTERNAL_FORMAT', -'INTERNAL_IMAGE_HEIGHT', 'INTERNAL_IMAGE_WIDTH', 'INTRA', 'JPEG', -'JPEG_ERROR', 'JPEG_NUM_PARAMS', 'JPEG_QUALITY_FACTOR', -'JPEG_QUANTIZATION_TABLES', 'JPEG_SOFTWARE', 'JPEG_STREAM_HEADERS', -'KEYFRAME', 'LAST_FRAME_INDEX', 'LAYER', 'LUMA_THRESHOLD', -'MAX_NUMBER_OF_AUDIO_ALGORITHMS', 'MAX_NUMBER_OF_ORIGINAL_FORMATS', -'MAX_NUMBER_OF_PARAMS', 'MAX_NUMBER_OF_VIDEO_ALGORITHMS', 'MONO', -'MPEG_VIDEO', 'MVC1', 'MVC2', 'MVC2_BLENDING', 'MVC2_BLENDING_OFF', -'MVC2_BLENDING_ON', 'MVC2_CHROMA_THRESHOLD', 'MVC2_EDGE_THRESHOLD', -'MVC2_ERROR', 'MVC2_LUMA_THRESHOLD', 'NEXT_NOT_AVAILABLE', -'NOISE_MARGIN', 'NONE', 'NUMBER_OF_FRAMES', 'NUMBER_OF_PARAMS', -'ORIENTATION', 'ORIGINAL_FORMAT', 'OpenCompressor', -'OpenDecompressor', 'PARAM_OUT_OF_RANGE', 'PREDICTED', 'PREROLL', -'ParamID', 'ParamNumber', 'ParamType', 'QUALITY_FACTOR', -'QUALITY_LEVEL', 'QueryAlgorithms', 'QueryMaxHeaderSize', -'QueryScheme', 'QuerySchemeFromName', 'RANGE_VALUE', 'RGB', 'RGB332', -'RGB8', 'RGBA', 'RGBX', 'RLE', 'RLE24', 'RTR', 'RTR1', -'RTR_QUALITY_LEVEL', 'SAMPLES_PER_TILE', 'SCHEME_BUSY', -'SCHEME_NOT_AVAILABLE', 'SPEED', 'STEREO_INTERLEAVED', -'STREAM_HEADERS', 'SetDefault', 'SetMax', 'SetMin', 'TILE_THRESHOLD', -'TOP_DOWN', 'ULAW', 'UNCOMPRESSED', 'UNCOMPRESSED_AUDIO', -'UNCOMPRESSED_VIDEO', 'UNKNOWN_SCHEME', 'VIDEO', 'VideoFormatName', -'Y', 'YCbCr', 'YCbCr422', 'YCbCr422DC', 'YCbCr422HC', 'YUV', 'YUV422', -'YUV422DC', 'YUV422HC', '__doc__', '__name__', 'cvt_type', 'error'] - - -# This is a very inobtrusive test for the existence of the cl -# module and all its attributes. - -def main(): - # touch all the attributes of al without doing anything - if verbose: - print('Touching cl module attributes...') - for attr in clattrs: - if verbose: - print('touching: ', attr) - getattr(cl, attr) - -main() diff --git a/Lib/test/test_commands.py b/Lib/test/test_commands.py index d899d66..1b84306 100644 --- a/Lib/test/test_commands.py +++ b/Lib/test/test_commands.py @@ -4,10 +4,6 @@ ''' import unittest import os, tempfile, re -import warnings - -warnings.filterwarnings('ignore', r".*commands.getstatus.. is deprecated", - DeprecationWarning) from test.test_support import TestSkipped, run_unittest, reap_children from commands import * @@ -42,28 +38,10 @@ class CommandTests(unittest.TestCase): if dir is not None: os.rmdir(dir) - def test_getstatus(self): - # This pattern should match 'ls -ld /.' on any posix - # system, however perversely configured. Even on systems - # (e.g., Cygwin) where user and group names can have spaces: - # drwxr-xr-x 15 Administ Domain U 4096 Aug 12 12:50 / - # drwxr-xr-x 15 Joe User My Group 4096 Aug 12 12:50 / - # Note that the first case above has a space in the group name - # while the second one has a space in both names. - pat = r'''d......... # It is a directory. - \+? # It may have ACLs. - \s+\d+ # It has some number of links. - [^/]* # Skip user, group, size, and date. - /\. # and end with the name of the file. - ''' - - self.assert_(re.match(pat, getstatus("/."), re.VERBOSE)) - def test_main(): run_unittest(CommandTests) reap_children() - if __name__ == "__main__": test_main() diff --git a/Lib/test/test_gl.py b/Lib/test/test_gl.py deleted file mode 100755 index adae10e..0000000 --- a/Lib/test/test_gl.py +++ /dev/null @@ -1,150 +0,0 @@ -#! /usr/bin/env python -"""Very simple test script for the SGI gl library extension module - taken mostly from the documentation. - Roger E. Masse -""" -from test.test_support import verbose, TestSkipped -import gl, GL, time - -glattrs = ['RGBcolor', 'RGBcursor', 'RGBmode', 'RGBrange', 'RGBwritemask', -'__doc__', '__name__', 'addtopup', 'altgetmatrix', 'arc', 'arcf', -'arcfi', 'arcfs', 'arci', 'arcs', 'attachcursor', 'backbuffer', -'backface', 'bbox2', 'bbox2i', 'bbox2s', 'bgnclosedline', 'bgnline', -'bgnpoint', 'bgnpolygon', 'bgnsurface', 'bgntmesh', 'bgntrim', -'blankscreen', 'blanktime', 'blendfunction', 'blink', 'c3f', 'c3i', -'c3s', 'c4f', 'c4i', 'c4s', 'callobj', 'charstr', 'chunksize', 'circ', -'circf', 'circfi', 'circfs', 'circi', 'circs', 'clear', -'clearhitcode', 'clkoff', 'clkon', 'closeobj', 'cmode', 'cmov', -'cmov2', 'cmov2i', 'cmov2s', 'cmovi', 'cmovs', 'color', 'colorf', -'compactify', 'concave', 'cpack', 'crv', 'crvn', 'curorigin', -'cursoff', 'curson', 'curstype', 'curvebasis', 'curveit', -'curveprecision', 'cyclemap', 'czclear', 'defbasis', 'defcursor', -'deflinestyle', 'delobj', 'deltag', 'depthcue', 'devport', 'dglclose', -'dglopen', 'dither', 'dopup', 'doublebuffer', 'draw', 'draw2', -'draw2i', 'draw2s', 'drawi', 'drawmode', 'draws', 'editobj', -'endclosedline', 'endfullscrn', 'endline', 'endpick', 'endpoint', -'endpolygon', 'endpupmode', 'endselect', 'endsurface', 'endtmesh', -'endtrim', 'finish', 'font', 'foreground', 'freepup', 'frontbuffer', -'fudge', 'fullscrn', 'gRGBcolor', 'gRGBmask', 'gammaramp', 'gbegin', -'gconfig', 'genobj', 'gentag', 'getbackface', 'getbuffer', -'getbutton', 'getcmmode', 'getcolor', 'getcpos', 'getcursor', -'getdcm', 'getdepth', 'getdescender', 'getdisplaymode', 'getdrawmode', -'getfont', 'getgdesc', 'getgpos', 'getheight', 'gethitcode', -'getlsbackup', 'getlsrepeat', 'getlstyle', 'getlwidth', 'getmap', -'getmatrix', 'getmcolor', 'getmmode', 'getmonitor', -'getnurbsproperty', 'getopenobj', 'getorigin', 'getothermonitor', -'getpattern', 'getplanes', 'getport', 'getresetls', 'getscrmask', -'getshade', 'getsize', 'getsm', 'gettp', 'getvaluator', 'getvideo', -'getviewport', 'getwritemask', 'getzbuffer', 'gewrite', 'gflush', -'ginit', 'glcompat', 'greset', 'gselect', 'gsync', 'gversion', -'iconsize', 'icontitle', 'imakebackground', 'initnames', 'ismex', -'isobj', 'isqueued', 'istag', 'keepaspect', 'lRGBrange', 'lampoff', -'lampon', 'linesmooth', 'linewidth', 'lmbind', 'lmcolor', 'lmdef', -'loadmatrix', 'loadname', 'logicop', 'lookat', 'lrectread', -'lrectwrite', 'lsbackup', 'lsetdepth', 'lshaderange', 'lsrepeat', -'makeobj', 'maketag', 'mapcolor', 'mapw', 'mapw2', 'maxsize', -'minsize', 'mmode', 'move', 'move2', 'move2i', 'move2s', 'movei', -'moves', 'multimap', 'multmatrix', 'n3f', 'newpup', 'newtag', -'noborder', 'noise', 'noport', 'normal', 'nurbscurve', 'nurbssurface', -'nvarray', 'objdelete', 'objinsert', 'objreplace', 'onemap', 'ortho', -'ortho2', 'overlay', 'packrect', 'pagecolor', 'pagewritemask', -'passthrough', 'patch', 'patchbasis', 'patchcurves', 'patchprecision', -'pclos', 'pdr', 'pdr2', 'pdr2i', 'pdr2s', 'pdri', 'pdrs', -'perspective', 'pick', 'picksize', 'pixmode', 'pmv', 'pmv2', 'pmv2i', -'pmv2s', 'pmvi', 'pmvs', 'pnt', 'pnt2', 'pnt2i', 'pnt2s', 'pnti', -'pnts', 'pntsmooth', 'polarview', 'polf', 'polf2', 'polf2i', 'polf2s', -'polfi', 'polfs', 'poly', 'poly2', 'poly2i', 'poly2s', 'polyi', -'polys', 'popattributes', 'popmatrix', 'popname', 'popviewport', -'prefposition', 'prefsize', 'pupmode', 'pushattributes', 'pushmatrix', -'pushname', 'pushviewport', 'pwlcurve', 'qdevice', 'qenter', 'qgetfd', -'qread', 'qreset', 'qtest', 'rcrv', 'rcrvn', 'rdr', 'rdr2', 'rdr2i', -'rdr2s', 'rdri', 'rdrs', 'readdisplay', 'readsource', 'rect', -'rectcopy', 'rectf', 'rectfi', 'rectfs', 'recti', 'rects', 'rectzoom', -'resetls', 'reshapeviewport', 'ringbell', 'rmv', 'rmv2', 'rmv2i', -'rmv2s', 'rmvi', 'rmvs', 'rot', 'rotate', 'rpatch', 'rpdr', 'rpdr2', -'rpdr2i', 'rpdr2s', 'rpdri', 'rpdrs', 'rpmv', 'rpmv2', 'rpmv2i', -'rpmv2s', 'rpmvi', 'rpmvs', 'sbox', 'sboxf', 'sboxfi', 'sboxfs', -'sboxi', 'sboxs', 'scale', 'screenspace', 'scrmask', 'setbell', -'setcursor', 'setdepth', 'setlinestyle', 'setmap', 'setmonitor', -'setnurbsproperty', 'setpattern', 'setpup', 'setshade', 'setvaluator', -'setvideo', 'shademodel', 'shaderange', 'singlebuffer', 'smoothline', -'spclos', 'splf', 'splf2', 'splf2i', 'splf2s', 'splfi', 'splfs', -'stepunit', 'strwidth', 'subpixel', 'swapbuffers', 'swapinterval', -'swaptmesh', 'swinopen', 'textcolor', 'textinit', 'textport', -'textwritemask', 'tie', 'tpoff', 'tpon', 'translate', 'underlay', -'unpackrect', 'unqdevice', 'v2d', 'v2f', 'v2i', 'v2s', 'v3d', 'v3f', -'v3i', 'v3s', 'v4d', 'v4f', 'v4i', 'v4s', 'varray', 'videocmd', -'viewport', 'vnarray', 'winattach', 'winclose', 'winconstraints', -'windepth', 'window', 'winget', 'winmove', 'winopen', 'winpop', -'winposition', 'winpush', 'winset', 'wintitle', 'wmpack', 'writemask', -'writepixels', 'xfpt', 'xfpt2', 'xfpt2i', 'xfpt2s', 'xfpt4', 'xfpt4i', -'xfpt4s', 'xfpti', 'xfpts', 'zbuffer', 'zclear', 'zdraw', 'zfunction', -'zsource', 'zwritemask'] - -def main(): - # insure that we at least have an X display before continuing. - import os - try: - display = os.environ['DISPLAY'] - except: - raise TestSkipped, "No $DISPLAY -- skipping gl test" - - # touch all the attributes of gl without doing anything - if verbose: - print('Touching gl module attributes...') - for attr in glattrs: - if verbose: - print('touching: ', attr) - getattr(gl, attr) - - # create a small 'Crisscross' window - if verbose: - print('Creating a small "CrissCross" window...') - print('foreground') - gl.foreground() - if verbose: - print('prefposition') - gl.prefposition(500, 900, 500, 900) - if verbose: - print('winopen "CrissCross"') - w = gl.winopen('CrissCross') - if verbose: - print('clear') - gl.clear() - if verbose: - print('ortho2') - gl.ortho2(0.0, 400.0, 0.0, 400.0) - if verbose: - print('color WHITE') - gl.color(GL.WHITE) - if verbose: - print('color RED') - gl.color(GL.RED) - if verbose: - print('bgnline') - gl.bgnline() - if verbose: - print('v2f') - gl.v2f(0.0, 0.0) - gl.v2f(400.0, 400.0) - if verbose: - print('endline') - gl.endline() - if verbose: - print('bgnline') - gl.bgnline() - if verbose: - print('v2i') - gl.v2i(400, 0) - gl.v2i(0, 400) - if verbose: - print('endline') - gl.endline() - if verbose: - print('Displaying window for 2 seconds...') - time.sleep(2) - if verbose: - print('winclose') - gl.winclose(w) - -main() diff --git a/Lib/test/test_imgfile.py b/Lib/test/test_imgfile.py deleted file mode 100755 index 4e31cb1..0000000 --- a/Lib/test/test_imgfile.py +++ /dev/null @@ -1,116 +0,0 @@ -#! /usr/bin/env python - -"""Simple test script for imgfile.c - Roger E. Masse -""" - -from test.test_support import verbose, unlink, findfile - -import imgfile, uu, os - - -def main(): - - uu.decode(findfile('testrgb.uue'), 'test.rgb') - uu.decode(findfile('greyrgb.uue'), 'greytest.rgb') - - # Test a 3 byte color image - testimage('test.rgb') - - # Test a 1 byte greyscale image - testimage('greytest.rgb') - - unlink('test.rgb') - unlink('greytest.rgb') - -def testimage(name): - """Run through the imgfile's battery of possible methods - on the image passed in name. - """ - - import sys - import os - - outputfile = '/tmp/deleteme' - - # try opening the name directly - try: - # This function returns a tuple (x, y, z) where x and y are the size - # of the image in pixels and z is the number of bytes per pixel. Only - # 3 byte RGB pixels and 1 byte greyscale pixels are supported. - sizes = imgfile.getsizes(name) - except imgfile.error: - # get a more qualified path component of the script... - if __name__ == '__main__': - ourname = sys.argv[0] - else: # ...or the full path of the module - ourname = sys.modules[__name__].__file__ - - parts = ourname.split(os.sep) - parts[-1] = name - name = os.sep.join(parts) - sizes = imgfile.getsizes(name) - if verbose: - print('Opening test image: %s, sizes: %s' % (name, str(sizes))) - # This function reads and decodes the image on the specified file, - # and returns it as a python string. The string has either 1 byte - # greyscale pixels or 4 byte RGBA pixels. The bottom left pixel - # is the first in the string. This format is suitable to pass - # to gl.lrectwrite, for instance. - image = imgfile.read(name) - - # This function writes the RGB or greyscale data in data to - # image file file. x and y give the size of the image, z is - # 1 for 1 byte greyscale images or 3 for RGB images (which - # are stored as 4 byte values of which only the lower three - # bytes are used). These are the formats returned by gl.lrectread. - if verbose: - print('Writing output file') - imgfile.write (outputfile, image, sizes[0], sizes[1], sizes[2]) - - - if verbose: - print('Opening scaled test image: %s, sizes: %s' % (name, str(sizes))) - # This function is identical to read but it returns an image that - # is scaled to the given x and y sizes. If the filter and blur - # parameters are omitted scaling is done by simply dropping - # or duplicating pixels, so the result will be less than perfect, - # especially for computer-generated images. Alternatively, - # you can specify a filter to use to smoothen the image after - # scaling. The filter forms supported are 'impulse', 'box', - # 'triangle', 'quadratic' and 'gaussian'. If a filter is - # specified blur is an optional parameter specifying the - # blurriness of the filter. It defaults to 1.0. readscaled - # makes no attempt to keep the aspect ratio correct, so that - # is the users' responsibility. - if verbose: - print('Filtering with "impulse"') - simage = imgfile.readscaled (name, sizes[0]/2, sizes[1]/2, 'impulse', 2.0) - - # This function sets a global flag which defines whether the - # scan lines of the image are read or written from bottom to - # top (flag is zero, compatible with SGI GL) or from top to - # bottom(flag is one, compatible with X). The default is zero. - if verbose: - print('Switching to X compatibility') - imgfile.ttob (1) - - if verbose: - print('Filtering with "triangle"') - simage = imgfile.readscaled (name, sizes[0]/2, sizes[1]/2, 'triangle', 3.0) - if verbose: - print('Switching back to SGI compatibility') - imgfile.ttob (0) - - if verbose: print('Filtering with "quadratic"') - simage = imgfile.readscaled (name, sizes[0]/2, sizes[1]/2, 'quadratic') - if verbose: print('Filtering with "gaussian"') - simage = imgfile.readscaled (name, sizes[0]/2, sizes[1]/2, 'gaussian', 1.0) - - if verbose: - print('Writing output file') - imgfile.write (outputfile, simage, sizes[0]/2, sizes[1]/2, sizes[2]) - - os.unlink(outputfile) - -main() diff --git a/Lib/test/test_listcomps.py b/Lib/test/test_listcomps.py index 6590777..684b716 100644 --- a/Lib/test/test_listcomps.py +++ b/Lib/test/test_listcomps.py @@ -435,7 +435,7 @@ def test_main(verbose=None): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_doctest(test_genexps, verbose) + test_support.run_doctest(test_listcomps, verbose) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_setcomps.py b/Lib/test/test_setcomps.py index 021fd96..7b09527 100644 --- a/Lib/test/test_setcomps.py +++ b/Lib/test/test_setcomps.py @@ -436,15 +436,15 @@ __test__ = {'doctests' : doctests} def test_main(verbose=None): import sys from test import test_support - from test import test_listcomps - test_support.run_doctest(test_listcomps, verbose) + from test import test_setcomps + test_support.run_doctest(test_setcomps, verbose) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in range(len(counts)): - test_support.run_doctest(test_genexps, verbose) + test_support.run_doctest(test_setcomps, verbose) gc.collect() counts[i] = sys.gettotalrefcount() print(counts) diff --git a/Lib/test/test_unpack_ex.py b/Lib/test/test_unpack_ex.py new file mode 100644 index 0000000..557e449 --- /dev/null +++ b/Lib/test/test_unpack_ex.py @@ -0,0 +1,157 @@ +# Tests for extended unpacking, starred expressions. + +doctests = """ + +Unpack tuple + + >>> t = (1, 2, 3) + >>> a, *b, c = t + >>> a == 1 and b == [2] and c == 3 + True + +Unpack list + + >>> l = [4, 5, 6] + >>> a, *b = l + >>> a == 4 and b == [5, 6] + True + +Unpack implied tuple + + >>> *a, = 7, 8, 9 + >>> a == [7, 8, 9] + True + +Unpack string... fun! + + >>> a, *b = 'one' + >>> a == 'o' and b == ['n', 'e'] + True + +Unpack long sequence + + >>> a, b, c, *d, e, f, g = range(10) + >>> (a, b, c, d, e, f, g) == (0, 1, 2, [3, 4, 5, 6], 7, 8, 9) + True + +Unpack short sequence + + >>> a, *b, c = (1, 2) + >>> a == 1 and c == 2 and b == [] + True + +Unpack generic sequence + + >>> class Seq: + ... def __getitem__(self, i): + ... if i >= 0 and i < 3: return i + ... raise IndexError + ... + >>> a, *b = Seq() + >>> a == 0 and b == [1, 2] + True + +Unpack in for statement + + >>> for a, *b, c in [(1,2,3), (4,5,6,7)]: + ... print(a, b, c) + ... + 1 [2] 3 + 4 [5, 6] 7 + +Unpack in list + + >>> [a, *b, c] = range(5) + >>> a == 0 and b == [1, 2, 3] and c == 4 + True + +Multiple targets + + >>> a, *b, c = *d, e = range(5) + >>> a == 0 and b == [1, 2, 3] and c == 4 and d == [0, 1, 2, 3] and e == 4 + True + +Now for some failures + +Unpacking non-sequence + + >>> a, *b = 7 + Traceback (most recent call last): + ... + TypeError: 'int' object is not iterable + +Unpacking sequence too short + + >>> a, *b, c, d, e = Seq() + Traceback (most recent call last): + ... + ValueError: need more than 3 values to unpack + +Unpacking a sequence where the test for too long raises a different kind of +error + + >>> class BozoError(Exception): + ... pass + ... + >>> class BadSeq: + ... def __getitem__(self, i): + ... if i >= 0 and i < 3: + ... return i + ... elif i == 3: + ... raise BozoError + ... else: + ... raise IndexError + ... + +Trigger code while not expecting an IndexError (unpack sequence too long, wrong +error) + + >>> a, *b, c, d, e = BadSeq() + Traceback (most recent call last): + ... + test.test_unpack_ex.BozoError + +Now some general starred expressions (all fail). + + >>> a, *b, c, *d, e = range(10) # doctest:+ELLIPSIS + Traceback (most recent call last): + ... + SyntaxError: two starred expressions in assignment (...) + + >>> [*b, *c] = range(10) # doctest:+ELLIPSIS + Traceback (most recent call last): + ... + SyntaxError: two starred expressions in assignment (...) + + >>> *a = range(10) # doctest:+ELLIPSIS + Traceback (most recent call last): + ... + SyntaxError: starred assignment target must be in a list or tuple (...) + + >>> *a # doctest:+ELLIPSIS + Traceback (most recent call last): + ... + SyntaxError: can use starred expression only as assignment target (...) + + >>> *1 # doctest:+ELLIPSIS + Traceback (most recent call last): + ... + SyntaxError: can use starred expression only as assignment target (...) + + >>> x = *a # doctest:+ELLIPSIS + Traceback (most recent call last): + ... + SyntaxError: can use starred expression only as assignment target (...) + +""" + +__test__ = {'doctests' : doctests} + +def test_main(verbose=False): + import sys + from test import test_support + from test import test_unpack_ex + test_support.run_doctest(test_unpack_ex, verbose) + +if __name__ == "__main__": + test_main(verbose=True) |