[Python-checkins] CVS: python/dist/src/Lib/test test_future3.py,NONE,1.3.2.1 test_socket_ssl.py,NONE,1.1.2.1 regrtest.py,1.41,1.41.2.1 test_future.py,1.3,1.3.6.1 test_htmlparser.py,1.3,1.3.2.1 test_largefile.py,1.4,1.4.8.1 test_os.py,1.3.2.1,1.3.2.2 test_support.py,1.25,1.25.2.1

Guido van Rossum gvanrossum@users.sourceforge.net
2001年8月20日 20:37:44 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv4055
Modified Files:
 Tag: r22a2-branch
	regrtest.py test_future.py test_htmlparser.py 
	test_largefile.py test_os.py test_support.py 
Added Files:
 Tag: r22a2-branch
	test_future3.py test_socket_ssl.py 
Log Message:
Merge trunk->branch
--- NEW FILE: test_future3.py ---
from __future__ import nested_scopes
from __future__ import division
from __future__ import nested_scopes
def f(x):
 def g(y):
 return y // x
 return g
print f(2)(5)
--- NEW FILE: test_socket_ssl.py ---
# 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
import urllib
urllib.urlopen('https://sf.net')
Index: regrtest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v
retrieving revision 1.41
retrieving revision 1.41.2.1
diff -C2 -d -r1.41 -r1.41.2.1
*** regrtest.py	2001年08月12日 21:53:08	1.41
--- regrtest.py	2001年08月21日 03:37:42	1.41.2.1
***************
*** 16,20 ****
 -r: random -- randomize test execution order
 -l: findleaks -- if GC is available detect tests that leak memory
! --have-resources -- run tests that require large resources (time/space)
 
 If non-option arguments are present, they are names for tests to run,
--- 16,21 ----
 -r: random -- randomize test execution order
 -l: findleaks -- if GC is available detect tests that leak memory
! -u: use -- specify which special resource intensive tests to run
! -h: help -- print this text and exit
 
 If non-option arguments are present, they are names for tests to run,
***************
*** 31,34 ****
--- 32,46 ----
 used instead of /tmp).
 
+ -u is used to specify which special resource intensive tests to run, such as
+ those requiring large file support or network connectivity. The argument is a
+ comma-separated list of words indicating the resources to test. Currently
+ only the following are defined:
+ 
+ largefile - It is okay to run some test that may create huge files. These
+ tests can take a long time and may consume >2GB of disk space
+ temporarily.
+ 
+ network - It is okay to run tests that use external network resource,
+ e.g. testing SSL support for sockets.
 """
 
***************
*** 42,48 ****
 import test_support
 
 def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
 exclude=0, single=0, randomize=0, findleaks=0,
! use_large_resources=0):
 """Execute a test suite.
 
--- 54,66 ----
 import test_support
 
+ def usage(code, msg=''):
+ print __doc__
+ if msg: print msg
+ sys.exit(code)
+ 
+ 
 def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
 exclude=0, single=0, randomize=0, findleaks=0,
! use_resources=None):
 """Execute a test suite.
 
***************
*** 61,66 ****
 files beginning with test_ will be used.
 
! The other seven default arguments (verbose, quiet, generate, exclude,
! single, randomize, and findleaks) allow programmers calling main()
 directly to set the values that would normally be set by flags on the
 command line.
--- 79,84 ----
 files beginning with test_ will be used.
 
! The other default arguments (verbose, quiet, generate, exclude, single,
! randomize, findleaks, and use_resources) allow programmers calling main()
 directly to set the values that would normally be set by flags on the
 command line.
***************
*** 69,89 ****
 
 try:
! opts, args = getopt.getopt(sys.argv[1:], 'vgqxsrl', ['have-resources'])
 except getopt.error, msg:
! print msg
! print __doc__
! return 2
 for o, a in opts:
! if o == '-v': verbose = verbose+1
! if o == '-q': quiet = 1; verbose = 0
! if o == '-g': generate = 1
! if o == '-x': exclude = 1
! if o == '-s': single = 1
! if o == '-r': randomize = 1
! if o == '-l': findleaks = 1
! if o == '--have-resources': use_large_resources = 1
 if generate and verbose:
! print "-g and -v don't go together!"
! return 2
 good = []
 bad = []
--- 87,126 ----
 
 try:
! opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrlu:',
! ['help', 'verbose', 'quiet', 'generate',
! 'exclude', 'single', 'random',
! 'findleaks', 'use='])
 except getopt.error, msg:
! usage(2, msg)
! 
! # Defaults
! if use_resources is None:
! use_resources = []
 for o, a in opts:
! if o in ('-h', '--help'):
! usage(0)
! elif o in ('-v', '--verbose'):
! verbose += 1
! elif o in ('-q', '--quiet'):
! quiet = 1;
! verbose = 0
! elif o in ('-g', '--generate'):
! generate = 1
! elif o in ('-x', '--exclude'):
! exclude = 1
! elif o in ('-s', '--single'):
! single = 1
! elif o in ('-r', '--randomize'):
! randomize = 1
! elif o in ('-l', '--findleaks'):
! findleaks = 1
! elif o in ('-u', '--use'):
! use_resources = [x.lower() for x in a.split(',')]
! for r in use_resources:
! if r not in ('largefile', 'network'):
! usage(1, 'Invalid -u/--use option: %s' % a)
 if generate and verbose:
! usage(2, "-g and -v don't go together!")
! 
 good = []
 bad = []
***************
*** 131,135 ****
 random.shuffle(tests)
 test_support.verbose = verbose # Tell tests to be moderately quiet
! test_support.use_large_resources = use_large_resources
 save_modules = sys.modules.keys()
 for test in tests:
--- 168,172 ----
 random.shuffle(tests)
 test_support.verbose = verbose # Tell tests to be moderately quiet
! test_support.use_resources = use_resources
 save_modules = sys.modules.keys()
 for test in tests:
***************
*** 198,203 ****
 os.unlink(filename)
 
! return len(bad) > 0
 
 STDTESTS = [
 'test_grammar',
--- 235,241 ----
 os.unlink(filename)
 
! sys.exit(len(bad) > 0)
 
+ 
 STDTESTS = [
 'test_grammar',
***************
*** 215,218 ****
--- 253,257 ----
 'test_future1',
 'test_future2',
+ 'test_future3',
 ]
 
***************
*** 347,351 ****
 
 class Compare:
- 
 def __init__(self, filename):
 if os.path.exists(filename):
--- 386,389 ----
***************
*** 452,455 ****
--- 490,494 ----
 test_pwd
 test_signal
+ test_socket_ssl
 test_socketserver
 test_sunaudiodev
***************
*** 467,470 ****
--- 506,510 ----
 test_nis
 test_ntpath
+ test_socket_ssl
 test_socketserver
 test_sunaudiodev
***************
*** 497,499 ****
 
 if __name__ == '__main__':
! sys.exit(main())
--- 537,539 ----
 
 if __name__ == '__main__':
! main()
Index: test_future.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_future.py,v
retrieving revision 1.3
retrieving revision 1.3.6.1
diff -C2 -d -r1.3 -r1.3.6.1
*** test_future.py	2001年04月18日 01:19:27	1.3
--- test_future.py	2001年08月21日 03:37:42	1.3.6.1
***************
*** 18,21 ****
--- 18,24 ----
 import test_future2
 
+ unload('test_future3')
+ import test_future3
+ 
 # The remaining tests should fail
 try:
Index: test_htmlparser.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_htmlparser.py,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C2 -d -r1.3 -r1.3.2.1
*** test_htmlparser.py	2001年08月03日 19:53:01	1.3
--- test_htmlparser.py	2001年08月21日 03:37:42	1.3.2.1
***************
*** 2,5 ****
--- 2,6 ----
 
 import HTMLParser
+ import pprint
 import sys
 import test_support
***************
*** 84,90 ****
 parser.feed(c)
 parser.close()
! self.assert_(parser.get_events() ==
! self.initial_events + events + self.final_events,
! parser.get_events())
 
 def _run_check_extra(self, source, events):
--- 85,92 ----
 parser.feed(c)
 parser.close()
! events = parser.get_events()
! self.assertEqual(events,
! self.initial_events + events + self.final_events,
! "got events:\n" + pprint.pformat(events))
 
 def _run_check_extra(self, source, events):
***************
*** 138,141 ****
--- 140,155 ----
 ])
 
+ def test_doctype_decl(self):
+ inside = """\
+ DOCTYPE html [
+ <!ELEMENT html - O EMPTY>
+ <!ATTLIST html
+ version CDATA #IMPLIED '4.0'>
+ <!-- comment -->
+ ]"""
+ self._run_check("<!%s>" % inside, [
+ ("decl", inside),
+ ])
+ 
 def test_bad_nesting(self):
 # Strangely, this *is* supposed to test that overlapping
***************
*** 149,152 ****
--- 163,176 ----
 ])
 
+ def test_bare_ampersands(self):
+ self._run_check("this text & contains & ampersands &", [
+ ("data", "this text & contains & ampersands &"),
+ ])
+ 
+ def test_bare_pointy_brackets(self):
+ self._run_check("this < text > contains < bare>pointy< brackets", [
+ ("data", "this < text > contains < bare>pointy< brackets"),
+ ])
+ 
 def test_attr_syntax(self):
 output = [
***************
*** 200,205 ****
 
 def test_starttag_junk_chars(self):
- self._parse_error("<")
- self._parse_error("<>")
 self._parse_error("</>")
 self._parse_error("</$>")
--- 224,227 ----
***************
*** 208,213 ****
 self._parse_error("<a<a>")
 self._parse_error("</a<a>")
- self._parse_error("<$")
- self._parse_error("<$>")
 self._parse_error("<!")
 self._parse_error("<a $>")
--- 230,233 ----
Index: test_largefile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_largefile.py,v
retrieving revision 1.4
retrieving revision 1.4.8.1
diff -C2 -d -r1.4 -r1.4.8.1
*** test_largefile.py	2001年04月10日 14:50:51	1.4
--- test_largefile.py	2001年08月21日 03:37:42	1.4.8.1
***************
*** 31,41 ****
 
 
! # on Windows this test comsumes large resources:
! # it takes a long time to build the >2GB file and takes >2GB of disk space
! # therefore test_support.use_large_resources must be defined to run this test
! if sys.platform[:3] == 'win' and not test_support.use_large_resources:
! raise test_support.TestSkipped, \
! "test requires %s bytes and a long time to run" % str(size)
! 
 
 
--- 31,42 ----
 
 
! # 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))
 
 
Index: test_os.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_os.py,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -C2 -d -r1.3.2.1 -r1.3.2.2
*** test_os.py	2001年08月19日 06:46:54	1.3.2.1
--- test_os.py	2001年08月21日 03:37:42	1.3.2.2
***************
*** 34,37 ****
--- 34,39 ----
 if not hasattr(os, "tempnam"):
 return
+ warnings.filterwarnings("ignore", "tempnam", RuntimeWarning,
+ "test_os")
 self.check_tempfile(os.tempnam())
 
***************
*** 56,59 ****
--- 58,63 ----
 if not hasattr(os, "tmpnam"):
 return
+ warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning,
+ "test_os")
 self.check_tempfile(os.tmpnam())
 
Index: test_support.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_support.py,v
retrieving revision 1.25
retrieving revision 1.25.2.1
diff -C2 -d -r1.25 -r1.25.2.1
*** test_support.py	2001年08月17日 18:39:24	1.25
--- test_support.py	2001年08月21日 03:37:42	1.25.2.1
***************
*** 20,25 ****
 """
 
! verbose = 1 # Flag set to 0 by regrtest.py
! use_large_resources = 1 # Flag set to 0 by regrtest.py
 
 def unload(name):
--- 20,25 ----
 """
 
! verbose = 1 # Flag set to 0 by regrtest.py
! use_resources = [] # Flag set to [] by regrtest.py
 
 def unload(name):
***************
*** 37,40 ****
--- 37,46 ----
 except os.error:
 pass
+ 
+ def requires(resource, msg=None):
+ if resource not in use_resources:
+ if msg is None:
+ msg = "Use of the `%s' resource not enabled" % resource
+ raise TestSkipped(msg)
 
 FUZZ = 1e-6

AltStyle によって変換されたページ (->オリジナル) /