Commits

Anonymous committed 6837135

the usual

  • Participants
  • Parent commits e4ea44b
  • Branches legacy-trunk

Comments (0)

Files changed (10)

File Lib/dos-8x3/stringio.py

 				self.buflist = []
 			self.buflist = [self.buf[:self.pos], s, self.buf[newpos:]]
 			self.buf = ''
+			if newpos > self.len:
+				self.len = newpos
 		else:
 			self.buflist.append(s)
 			self.len = newpos

File Lib/dos-8x3/test_cop.py

+import copy_reg
+
+class C:
+    pass
+
+
+try:
+    copy_reg.pickle(C, None, None)
+except TypeError, e:
+    print "Caught expected TypeError:"
+    print e
+else:
+    print "Failed to catch expected TypeError when registering a class type."
+
+
+print
+try:
+    copy_reg.pickle(type(1), "not a callable")
+except TypeError, e:
+    print "Caught expected TypeError:"
+    print e
+else:
+    print "Failed to catch TypeError " \
+          "when registering a non-callable reduction function."
+
+
+print
+try:
+    copy_reg.pickle(type(1), int, "not a callable")
+except TypeError, e:
+    print "Caught expected TypeError:"
+    print e
+else:
+    print "Failed to catch TypeError " \
+          "when registering a non-callable constructor."

File Lib/dos-8x3/test_fcn.py

 if verbose:
     print 'Status from fnctl with O_NONBLOCK: ', rv
     
-if sys.platform in ('netbsd1',
+if sys.platform in ('netbsd1', 'Darwin1.2',
                     'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5',
                     'bsdos2', 'bsdos3', 'bsdos4',
                     'openbsd', 'openbsd2'):

File Lib/dos-8x3/test_gra.py

 print >> sys.stdout, 0 or 1, 0 or 1,
 print >> sys.stdout, 0 or 1
 
-# test print >> None
+# test printing to an instance
 class Gulp:
 	def write(self, msg): pass
 
+gulp = Gulp()
+print >> gulp, 1, 2, 3
+print >> gulp, 1, 2, 3,
+print >> gulp
+print >> gulp, 0 or 1, 0 or 1,
+print >> gulp, 0 or 1
+
+# test print >> None
 def driver():
 	oldstdout = sys.stdout
 	sys.stdout = Gulp()

File Lib/dos-8x3/test_mat.py

 print 'tanh'
 testit('tanh(0)', math.tanh(0), 0)
 testit('tanh(1)+tanh(-1)', math.tanh(1)+math.tanh(-1), 0)
+
+print 'exceptions'  # oooooh, *this* is a x-platform gamble!  good luck
+
+try:
+    x = math.exp(-1000000000)
+except:
+    # mathmodule.c is failing to weed out underflows from libm, or
+    # we've got an fp format with huge dynamic range
+    raise TestFailed("underflowing exp() should not have rasied an exception")
+if x != 0:
+    raise TestFailed("underflowing exp() should have returned 0")
+
+# If this fails, probably using a strict IEEE-754 conforming libm, and x
+# is +Inf afterwards.  But Python wants overflows detected by default.
+try:
+    x = math.exp(1000000000)
+except OverflowError:
+    pass
+else:
+    raise TestFailed("overflowing exp() didn't trigger OverflowError")
+
+# If this fails, it could be a puzzle.  One odd possibility is that
+# mathmodule.c's CHECK() macro is getting confused while comparing
+# Inf (HUGE_VAL) to a NaN, and artificially setting errno to ERANGE
+# as a result (and so raising OverflowError instead).
+try:
+    x = math.sqrt(-1.0)
+except ValueError:
+    pass
+else:
+    raise TestFailed("sqrt(-1) didn't raise ValueError")

File Lib/dos-8x3/test_min.py

 tstfile = os.path.join(os.path.dirname(base), "test.xml")
 del base
 
-def confirm( test, testname="Test" ):
+def confirm(test, testname = "Test"):
     if test: 
         print "Passed " + testname
     else: 
         print "Failed " + testname
         raise Exception
 
-Node._debug=1
+Node._debug = 1
 
 def testParseFromFile():
     from StringIO import StringIO
-    dom=parse( StringIO( open( tstfile ).read() ) )
+    dom = parse(StringIO(open(tstfile).read()))
     dom.unlink()
     confirm(isinstance(dom,Document))
 
-def testGetElementsByTagName( ):
-    dom=parse( tstfile )
-    confirm( dom.getElementsByTagName( "LI" )==\
-            dom.documentElement.getElementsByTagName( "LI" ) )
+def testGetElementsByTagName():
+    dom = parse(tstfile)
+    confirm(dom.getElementsByTagName("LI") == \
+            dom.documentElement.getElementsByTagName("LI"))
     dom.unlink()
 
-def testInsertBefore( ):
-    dom=parse( tstfile )
-    docel=dom.documentElement
+def testInsertBefore():
+    dom = parse(tstfile)
+    docel = dom.documentElement
     #docel.insertBefore( dom.createProcessingInstruction("a", "b"),
     #                        docel.childNodes[1])
                             
     #docel.insertBefore( dom.createProcessingInstruction("a", "b"),
     #                        docel.childNodes[0])
 
-    #confirm( docel.childNodes[0].tet=="a" )
-    #confirm( docel.childNodes[2].tet=="a" )
+    #confirm( docel.childNodes[0].tet == "a")
+    #confirm( docel.childNodes[2].tet == "a")
     dom.unlink()
 
 def testAppendChild():
-    dom=parse( tstfile )
-    dom.documentElement.appendChild( dom.createComment( u"Hello" ))
-    confirm( dom.documentElement.childNodes[-1].nodeName=="#comment" )
-    confirm( dom.documentElement.childNodes[-1].data=="Hello" )
+    dom = parse(tstfile)
+    dom.documentElement.appendChild(dom.createComment(u"Hello"))
+    confirm(dom.documentElement.childNodes[-1].nodeName == "#comment")
+    confirm(dom.documentElement.childNodes[-1].data == "Hello")
     dom.unlink()
 
 def testNonZero():
-    dom=parse( tstfile )
-    confirm( dom )# should not be zero
-    dom.appendChild( dom.createComment( "foo" ) )
-    confirm( not dom.childNodes[-1].childNodes )
+    dom = parse(tstfile)
+    confirm(dom)# should not be zero
+    dom.appendChild(dom.createComment("foo"))
+    confirm(not dom.childNodes[-1].childNodes)
     dom.unlink()
 
 def testUnlink():
-    dom=parse( tstfile )
+    dom = parse(tstfile)
     dom.unlink()
 
 def testElement():
-    dom=Document()
-    dom.appendChild( dom.createElement( "abc" ) )
-    confirm( dom.documentElement )
+    dom = Document()
+    dom.appendChild(dom.createElement("abc"))
+    confirm(dom.documentElement)
     dom.unlink()
 
 def testAAA():
-    dom=parseString( "<abc/>" )
-    el=dom.documentElement
-    el.setAttribute( "spam", "jam2" )
+    dom = parseString("<abc/>")
+    el = dom.documentElement
+    el.setAttribute("spam", "jam2")
     dom.unlink()
 
 def testAAB():
-    dom=parseString( "<abc/>" )
-    el=dom.documentElement
-    el.setAttribute( "spam", "jam" )
-    el.setAttribute( "spam", "jam2" )
+    dom = parseString("<abc/>")
+    el = dom.documentElement
+    el.setAttribute("spam", "jam")
+    el.setAttribute("spam", "jam2")
     dom.unlink()
 
 def testAddAttr():
-    dom=Document()
-    child=dom.appendChild( dom.createElement( "abc" ) )
+    dom = Document()
+    child = dom.appendChild(dom.createElement("abc"))
 
-    child.setAttribute( "def", "ghi" )
-    confirm( child.getAttribute( "def" )=="ghi" )
-    confirm( child.attributes["def"].value=="ghi" )
+    child.setAttribute("def", "ghi")
+    confirm(child.getAttribute("def") == "ghi")
+    confirm(child.attributes["def"].value == "ghi")
 
-    child.setAttribute( "jkl", "mno" )
-    confirm( child.getAttribute( "jkl" )=="mno" )
-    confirm( child.attributes["jkl"].value=="mno" )
+    child.setAttribute("jkl", "mno")
+    confirm(child.getAttribute("jkl") == "mno")
+    confirm(child.attributes["jkl"].value == "mno")
 
-    confirm( len( child.attributes )==2 )
+    confirm(len(child.attributes) == 2)
 
-    child.setAttribute( "def", "newval" )
-    confirm( child.getAttribute( "def" )=="newval" )
-    confirm( child.attributes["def"].value=="newval" )
+    child.setAttribute("def", "newval")
+    confirm(child.getAttribute("def") == "newval")
+    confirm(child.attributes["def"].value == "newval")
 
-    confirm( len( child.attributes )==2 )
+    confirm(len(child.attributes) == 2)
     dom.unlink()
 
 def testDeleteAttr():
-    dom=Document()
-    child=dom.appendChild( dom.createElement( "abc" ) )
+    dom = Document()
+    child = dom.appendChild(dom.createElement("abc"))
 
-    confirm( len( child.attributes)==0 )
-    child.setAttribute( "def", "ghi" )
-    confirm( len( child.attributes)==1 )
+    confirm(len(child.attributes) == 0)
+    child.setAttribute("def", "ghi")
+    confirm(len(child.attributes) == 1)
     del child.attributes["def"]
-    confirm( len( child.attributes)==0 )
+    confirm(len(child.attributes) == 0)
     dom.unlink()
 
 def testRemoveAttr():
-    dom=Document()
-    child=dom.appendChild( dom.createElement( "abc" ) )
+    dom = Document()
+    child = dom.appendChild(dom.createElement("abc"))
 
-    child.setAttribute( "def", "ghi" )
-    confirm( len( child.attributes)==1 )
-    child.removeAttribute("def" )
-    confirm( len( child.attributes)==0 )
+    child.setAttribute("def", "ghi")
+    confirm(len(child.attributes) == 1)
+    child.removeAttribute("def")
+    confirm(len(child.attributes) == 0)
 
     dom.unlink()
 
 def testRemoveAttrNS():
-    dom=Document()
-    child=dom.appendChild( 
-            dom.createElementNS( "http://www.python.org", "python:abc" ) )
-    child.setAttributeNS( "http://www.w3.org", "xmlns:python", 
-                                            "http://www.python.org" )
-    child.setAttributeNS( "http://www.python.org", "python:abcattr", "foo" )
-    confirm( len( child.attributes )==2 )
-    child.removeAttributeNS( "http://www.python.org", "abcattr" )
-    confirm( len( child.attributes )==1 )
+    dom = Document()
+    child = dom.appendChild(
+            dom.createElementNS("http://www.python.org", "python:abc"))
+    child.setAttributeNS("http://www.w3.org", "xmlns:python", 
+                                            "http://www.python.org")
+    child.setAttributeNS("http://www.python.org", "python:abcattr", "foo")
+    confirm(len(child.attributes) == 2)
+    child.removeAttributeNS("http://www.python.org", "abcattr")
+    confirm(len(child.attributes) == 1)
 
     dom.unlink()
     
 def testRemoveAttributeNode():
-    dom=Document()
-    child=dom.appendChild( dom.createElement( "foo" ) )
-    child.setAttribute( "spam", "jam" )
-    confirm( len( child.attributes )==1 )
-    node=child.getAttributeNode( "spam" )
-    child.removeAttributeNode( node )
-    confirm( len( child.attributes )==0 )
+    dom = Document()
+    child = dom.appendChild(dom.createElement("foo"))
+    child.setAttribute("spam", "jam")
+    confirm(len(child.attributes) == 1)
+    node = child.getAttributeNode("spam")
+    child.removeAttributeNode(node)
+    confirm(len(child.attributes) == 0)
 
     dom.unlink()
 
 def testChangeAttr():
-    dom=parseString( "<abc/>" )
-    el=dom.documentElement
-    el.setAttribute( "spam", "jam" )
-    confirm( len( el.attributes )==1 )
-    el.setAttribute( "spam", "bam" )
-    confirm( len( el.attributes )==1 )
-    el.attributes["spam"]="ham"
-    confirm( len( el.attributes )==1 )
-    el.setAttribute( "spam2", "bam" )
-    confirm( len( el.attributes )==2 )
-    el.attributes[ "spam2"]= "bam2"
-    confirm( len( el.attributes )==2 )
+    dom = parseString("<abc/>")
+    el = dom.documentElement
+    el.setAttribute("spam", "jam")
+    confirm(len(el.attributes) == 1)
+    el.setAttribute("spam", "bam")
+    confirm(len(el.attributes) == 1)
+    el.attributes["spam"] = "ham"
+    confirm(len(el.attributes) == 1)
+    el.setAttribute("spam2", "bam")
+    confirm(len(el.attributes) == 2)
+    el.attributes[ "spam2"] = "bam2"
+    confirm(len(el.attributes) == 2)
     dom.unlink()
 
 def testGetAttrList():
 def testGetEmptyNodeListFromElementsByTagNameNS(): pass
 
 def testElementReprAndStr():
-    dom=Document()
-    el=dom.appendChild( dom.createElement( "abc" ) )
-    string1=repr( el )
-    string2=str( el )
-    confirm( string1==string2 )
+    dom = Document()
+    el = dom.appendChild(dom.createElement("abc"))
+    string1 = repr(el)
+    string2 = str(el)
+    confirm(string1 == string2)
     dom.unlink()
 
 # commented out until Fredrick's fix is checked in
 def _testElementReprAndStrUnicode():
-    dom=Document()
-    el=dom.appendChild( dom.createElement( u"abc" ) )
-    string1=repr( el )
-    string2=str( el )
-    confirm( string1==string2 )
+    dom = Document()
+    el = dom.appendChild(dom.createElement(u"abc"))
+    string1 = repr(el)
+    string2 = str(el)
+    confirm(string1 == string2)
     dom.unlink()
 
 # commented out until Fredrick's fix is checked in
 def _testElementReprAndStrUnicodeNS():
-    dom=Document()
-    el=dom.appendChild(
-        dom.createElementNS( u"http://www.slashdot.org", u"slash:abc" ))
-    string1=repr( el )
-    string2=str( el )
-    confirm( string1==string2 )
-    confirm( string1.find("slash:abc" )!=-1 )
+    dom = Document()
+    el = dom.appendChild(
+        dom.createElementNS(u"http://www.slashdot.org", u"slash:abc"))
+    string1 = repr(el)
+    string2 = str(el)
+    confirm(string1 == string2)
+    confirm(string1.find("slash:abc") != -1)
     dom.unlink()
-    confirm( len( Node.allnodes )==0 )
+    confirm(len(Node.allnodes) == 0)
 
 def testAttributeRepr():
-    dom=Document()
-    el=dom.appendChild( dom.createElement( u"abc" ) )
-    node=el.setAttribute( "abc", "def" )
-    confirm( str( node ) == repr( node ) )
+    dom = Document()
+    el = dom.appendChild(dom.createElement(u"abc"))
+    node = el.setAttribute("abc", "def")
+    confirm(str(node) == repr(node))
     dom.unlink()
-    confirm( len( Node.allnodes )==0 )
+    confirm(len(Node.allnodes) == 0)
 
 def testTextNodeRepr(): pass
 
     domstr = dom.toxml()
     dom.unlink()
     confirm(str == domstr)
-    confirm( len( Node.allnodes )==0 )
+    confirm(len(Node.allnodes) == 0)
 
 def testProcessingInstruction(): pass
 
 
 def testClonePIDeep(): pass
 
+def testSiblings():
+    doc = parseString("<doc><?pi?>text?<elm/></doc>")
+    root = doc.documentElement
+    (pi, text, elm) = root.childNodes
 
-names=globals().keys()
+    confirm(pi.nextSibling is text and 
+            pi.previousSibling is None and 
+            text.nextSibling is elm and 
+            text.previousSibling is pi and 
+            elm.nextSibling is None and 
+            elm.previousSibling is text, "testSiblings")
+
+    doc.unlink()
+
+def testParents():
+    doc = parseString("<doc><elm1><elm2/><elm2><elm3/></elm2></elm1></doc>")
+    root = doc.documentElement
+    elm1 = root.childNodes[0]
+    (elm2a, elm2b) = elm1.childNodes
+    elm3 = elm2b.childNodes[0]
+
+    confirm(root.parentNode is doc and
+            elm1.parentNode is root and
+            elm2a.parentNode is elm1 and
+            elm2b.parentNode is elm1 and
+            elm3.parentNode is elm2b, "testParents")
+
+    doc.unlink()
+
+def testSAX2DOM():
+    from xml.dom import pulldom
+
+    sax2dom = pulldom.SAX2DOM()
+    sax2dom.startDocument()
+    sax2dom.startElement("doc", {})
+    sax2dom.characters("text")
+    sax2dom.startElement("subelm", {})
+    sax2dom.characters("text")
+    sax2dom.endElement("subelm")
+    sax2dom.characters("text")    
+    sax2dom.endElement("doc")
+    sax2dom.endDocument()
+
+    doc = sax2dom.document
+    root = doc.documentElement
+    (text1, elm1, text2) = root.childNodes
+    text3 = elm1.childNodes[0]
+
+    confirm(text1.previousSibling is None and
+            text1.nextSibling is elm1 and
+            elm1.previousSibling is text1 and
+            elm1.nextSibling is text2 and
+            text2.previousSibling is elm1 and
+            text2.nextSibling is None and
+            text3.previousSibling is None and
+            text3.nextSibling is None, "testSAX2DOM - siblings")
+
+    confirm(root.parentNode is doc and
+            text1.parentNode is root and
+            elm1.parentNode is root and
+            text2.parentNode is root and
+            text3.parentNode is elm1, "testSAX2DOM - parents")
+            
+    doc.unlink()
+
+# --- MAIN PROGRAM
+    
+names = globals().keys()
 names.sort()
 
-works=1
+works = 1
 
 for name in names:
-    if name.startswith( "test" ):
-        func=globals()[name]
+    if name.startswith("test"):
+        func = globals()[name]
         try:
             func()
             print "Test Succeeded", name
             confirm(len(Node.allnodes) == 0,
                     "assertion: len(Node.allnodes) == 0")
-            if len( Node.allnodes ):
+            if len(Node.allnodes):
                 print "Garbage left over:"
                 if verbose:
                     print Node.allnodes.items()[0:10]
                     # Don't print specific nodes if repeatable results
                     # are needed
                     print len(Node.allnodes)
-            Node.allnodes={}
-        except Exception, e :
-            works=0
+            Node.allnodes = {}
+        except Exception, e:
+            works = 0
             print "Test Failed: ", name
-            apply( traceback.print_exception, sys.exc_info() )
+            traceback.print_exception(*sys.exc_info())
             print `e`
-            Node.allnodes={}
+            Node.allnodes = {}
 
 if works:
     print "All tests succeeded"

File Lib/dos-8x3/test_str.py

-#! /usr/bin/env python
+# Tests StringIO and cStringIO
 
-# Sanity checker for time.strftime
+def do_test(module):
+    s = ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"+'\n')*5
+    f = module.StringIO(s)
+    print f.read(10)
+    print f.readline()
+    print len(f.readlines(60))
 
-import time, calendar, sys, string, os, re
-from test_support import verbose
+    f = module.StringIO()
+    f.write('abcdef')
+    f.seek(3)
+    f.write('uvwxyz')
+    f.write('!')
+    print `f.getvalue()`
+    f.close()
+    f = module.StringIO()
+    f.write(s)
+    f.seek(10)
+    f.truncate()
+    print `f.getvalue()`
+    f.seek(0)
+    f.truncate(5)
+    print `f.getvalue()`
+    f.close()
+    try:
+        f.write("frobnitz")
+    except ValueError, e:
+        print "Caught expected ValueError writing to closed StringIO:"
+        print e
+    else:
+        print "Failed to catch ValueError writing to closed StringIO."
 
-def main():
-    global verbose
-    now = time.time()
-    strftest(now)
-    verbose = 0
-    # Try a bunch of dates and times,  chosen to vary through time of
-    # day and daylight saving time
-    for j in range(-5, 5):
-        for i in range(25):
-            strftest(now + (i + j*100)*23*3603)
-
-def strftest(now):
-    if verbose:
-        print "strftime test for", time.ctime(now)
-    nowsecs = str(long(now))[:-1]
-    gmt = time.gmtime(now)
-    now = time.localtime(now)
-
-    if now[3] < 12: ampm='(AM|am)'
-    else: ampm='(PM|pm)'
-
-    jan1 = time.localtime(time.mktime((now[0], 1, 1) + (0,)*6))
-
-    try:
-        if now[8]: tz = time.tzname[1]
-        else: tz = time.tzname[0]
-    except AttributeError:
-        tz = ''
-
-    if now[3] > 12: clock12 = now[3] - 12
-    elif now[3] > 0: clock12 = now[3]
-    else: clock12 = 12
-
-    expectations = (
-        ('%a', calendar.day_abbr[now[6]], 'abbreviated weekday name'),
-        ('%A', calendar.day_name[now[6]], 'full weekday name'),
-        ('%b', calendar.month_abbr[now[1]], 'abbreviated month name'),
-        ('%B', calendar.month_name[now[1]], 'full month name'),
-        # %c see below
-        ('%d', '%02d' % now[2], 'day of month as number (00-31)'),
-        ('%H', '%02d' % now[3], 'hour (00-23)'),
-        ('%I', '%02d' % clock12, 'hour (01-12)'),
-        ('%j', '%03d' % now[7], 'julian day (001-366)'),
-        ('%m', '%02d' % now[1], 'month as number (01-12)'),
-        ('%M', '%02d' % now[4], 'minute, (00-59)'),
-        ('%p', ampm, 'AM or PM as appropriate'),
-        ('%S', '%02d' % now[5], 'seconds of current time (00-60)'),
-        ('%U', '%02d' % ((now[7] + jan1[6])/7),
-         'week number of the year (Sun 1st)'),
-        ('%w', '0?%d' % ((1+now[6]) % 7), 'weekday as a number (Sun 1st)'),
-        ('%W', '%02d' % ((now[7] + (jan1[6] - 1)%7)/7),
-         'week number of the year (Mon 1st)'),
-        # %x see below
-        ('%X', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'),
-        ('%y', '%02d' % (now[0]%100), 'year without century'),
-        ('%Y', '%d' % now[0], 'year with century'),
-        # %Z see below
-        ('%%', '%', 'single percent sign'),
-        )
-
-    nonstandard_expectations = (
-        # These are standard but don't have predictable output
-        ('%c', fixasctime(time.asctime(now)), 'near-asctime() format'),
-        ('%x', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)),
-         '%m/%d/%y %H:%M:%S'),
-        ('%Z', '%s' % tz, 'time zone name'),
-
-        # These are some platform specific extensions
-        ('%D', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), 'mm/dd/yy'),
-        ('%e', '%2d' % now[2], 'day of month as number, blank padded ( 0-31)'),
-        ('%h', calendar.month_abbr[now[1]], 'abbreviated month name'),
-        ('%k', '%2d' % now[3], 'hour, blank padded ( 0-23)'),
-        ('%n', '\n', 'newline character'),
-        ('%r', '%02d:%02d:%02d %s' % (clock12, now[4], now[5], ampm),
-         '%I:%M:%S %p'),
-        ('%R', '%02d:%02d' % (now[3], now[4]), '%H:%M'),
-        ('%s', nowsecs, 'seconds since the Epoch in UCT'),
-        ('%t', '\t', 'tab character'),
-        ('%T', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'),
-        ('%3y', '%03d' % (now[0]%100),
-         'year without century rendered using fieldwidth'),
-        )
-
-    if verbose:
-        print "Strftime test, platform: %s, Python version: %s" % \
-              (sys.platform, string.split(sys.version)[0])
-
-    for e in expectations:
-        try:
-            result = time.strftime(e[0], now)
-        except ValueError, error:
-            print "Standard '%s' format gave error:" % e[0], error
-            continue
-        if re.match(e[1], result): continue
-        if not result or result[0] == '%':
-            print "Does not support standard '%s' format (%s)" % (e[0], e[2])
-        else:
-            print "Conflict for %s (%s):" % (e[0], e[2])
-            print "  Expected %s, but got %s" % (e[1], result)
-
-    for e in nonstandard_expectations:
-        try:
-            result = time.strftime(e[0], now)
-        except ValueError, result:
-            if verbose:
-                print "Error for nonstandard '%s' format (%s): %s" % \
-                      (e[0], e[2], str(result))
-            continue
-        if re.match(e[1], result):
-            if verbose:
-                print "Supports nonstandard '%s' format (%s)" % (e[0], e[2])
-        elif not result or result[0] == '%':
-            if verbose:
-                print "Does not appear to support '%s' format (%s)" % (e[0],
-                                                                       e[2])
-        else:
-            if verbose:
-                print "Conflict for nonstandard '%s' format (%s):" % (e[0],
-                                                                      e[2])
-                print "  Expected %s, but got %s" % (e[1], result)
-
-def fixasctime(s):
-    if s[8] == ' ':
-        s = s[:8] + '0' + s[9:]
-    return s
-
-main()
+# Don't bother testing cStringIO without
+import StringIO, cStringIO
+do_test(StringIO)
+do_test(cStringIO)

File Lib/dos-8x3/test_unp.py

 if a <> 0 or b <> 1 or c <> 2:
     raise TestFailed
 
+# single element unpacking, with extra syntax
+if verbose:
+    print 'unpack single tuple/list'
+st = (99,)
+sl = [100]
+a, = st
+if a <> 99:
+    raise TestFailed
+b, = sl
+if b <> 100:
+    raise TestFailed
+
 # now for some failures
 
 # unpacking non-sequence

File Lib/dos-8x3/test_url.py

+# Minimal test of the quote function
+import urllib
+
+chars = 'abcdefghijklmnopqrstuvwxyz'\
+        '\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356' \
+        '\357\360\361\362\363\364\365\366\370\371\372\373\374\375\376\377' \
+        'ABCDEFGHIJKLMNOPQRSTUVWXYZ' \
+        '\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317' \
+        '\320\321\322\323\324\325\326\330\331\332\333\334\335\336'
+
+expected = 'abcdefghijklmnopqrstuvwxyz%df%e0%e1%e2%e3%e4%e5%e6%e7%e8%e9%ea%eb%ec%ed%ee%ef%f0%f1%f2%f3%f4%f5%f6%f8%f9%fa%fb%fc%fd%fe%ffABCDEFGHIJKLMNOPQRSTUVWXYZ%c0%c1%c2%c3%c4%c5%c6%c7%c8%c9%ca%cb%cc%cd%ce%cf%d0%d1%d2%d3%d4%d5%d6%d8%d9%da%db%dc%dd%de'
+
+test = urllib.quote(chars)
+assert test == expected, "urllib.quote problem"
+test2 = urllib.unquote(expected)
+assert test2 == chars
+
+in1 = "abc/def"
+out1_1 = "abc/def"
+out1_2 = "abc%2fdef"
+
+assert urllib.quote(in1) == out1_1, "urllib.quote problem"
+assert urllib.quote(in1, '') == out1_2, "urllib.quote problem"
+
+in2 = "abc?def"
+out2_1 = "abc%3fdef"
+out2_2 = "abc?def"
+
+assert urllib.quote(in2) == out2_1, "urllib.quote problem"
+assert urllib.quote(in2, '?') == out2_2, "urllib.quote problem"
+
+

File Lib/dos-8x3/test_win.py

-# Ridiculously simple test of the winsound module for Windows.
+# Test the windows specific win32reg module.
+# Only win32reg functions not hit here: FlushKey, LoadKey and SaveKey
 
-import winsound
-for i in range(100, 2000, 100):
-    winsound.Beep(i, 75)
-print "Hopefully you heard some sounds increasing in frequency!"
+from _winreg import *
+import os, sys
 
+test_key_name = "SOFTWARE\\Python Registry Test Key - Delete Me"
+
+test_data = [
+    ("Int Value",     45,                                      REG_DWORD),
+    ("String Val",    "A string value",                        REG_SZ,),
+    (u"Unicode Val",  u"A Unicode value",                      REG_SZ,),
+    ("StringExpand",  "The path is %path%",                    REG_EXPAND_SZ),
+    ("UnicodeExpand", u"The path is %path%",                   REG_EXPAND_SZ),
+    ("Multi-string",  ["Lots", "of", "string", "values"],      REG_MULTI_SZ),
+    ("Multi-unicode", [u"Lots", u"of", u"unicode", u"values"], REG_MULTI_SZ),
+    ("Multi-mixed",   [u"Unicode", u"and", "string", "values"],REG_MULTI_SZ),
+    ("Raw Data",      ("binary"+chr(0)+"data"),                REG_BINARY),
+]
+
+def WriteTestData(root_key):
+    # Set the default value for this key.
+    SetValue(root_key, test_key_name, REG_SZ, "Default value")
+    key = CreateKey(root_key, test_key_name)
+    # Create a sub-key
+    sub_key = CreateKey(key, "sub_key")
+    # Give the sub-key some named values
+
+    for value_name, value_data, value_type in test_data:
+        SetValueEx(sub_key, value_name, 0, value_type, value_data)
+
+    # Check we wrote as many items as we thought.
+    nkeys, nvalues, since_mod = QueryInfoKey(key)
+    assert nkeys==1, "Not the correct number of sub keys"
+    assert nvalues==1, "Not the correct number of values"
+    nkeys, nvalues, since_mod = QueryInfoKey(sub_key)
+    assert nkeys==0, "Not the correct number of sub keys"
+    assert nvalues==len(test_data), "Not the correct number of values"
+    # Close this key this way...
+    # (but before we do, copy the key as an integer - this allows
+    # us to test that the key really gets closed).
+    int_sub_key = int(sub_key)
+    CloseKey(sub_key)
+    try:
+        QueryInfoKey(int_sub_key)
+        raise RuntimeError, "It appears the CloseKey() function does not close the actual key!"
+    except EnvironmentError:
+        pass
+    # ... and close that key that way :-)
+    int_key = int(key)
+    key.Close()
+    try:
+        QueryInfoKey(int_key)
+        raise RuntimeError, "It appears the key.Close() function does not close the actual key!"
+    except EnvironmentError:
+        pass
+
+def ReadTestData(root_key):
+    # Check we can get default value for this key.
+    val = QueryValue(root_key, test_key_name)
+    assert val=="Default value", "Registry didn't give back the correct value"
+
+    key = OpenKey(root_key, test_key_name)
+    # Read the sub-keys
+    sub_key = OpenKey(key, "sub_key")
+    # Check I can enumerate over the values.
+    index = 0
+    while 1:
+        try:
+            data = EnumValue(sub_key, index)
+        except EnvironmentError:
+            break
+        assert data in test_data, "Didn't read back the correct test data"
+        index = index + 1
+    assert index==len(test_data), "Didn't read the correct number of items"
+    # Check I can directly access each item
+    for value_name, value_data, value_type in test_data:
+        read_val, read_typ = QueryValueEx(sub_key, value_name)
+        assert read_val==value_data and read_typ == value_type, \
+               "Could not directly read the value"
+    sub_key.Close()
+    # Enumerate our main key.
+    read_val = EnumKey(key, 0)
+    assert read_val == "sub_key", "Read subkey value wrong"
+    try:
+        EnumKey(key, 1)
+        assert 0, "Was able to get a second key when I only have one!"
+    except EnvironmentError:
+        pass
+
+    key.Close()
+
+def DeleteTestData(root_key):
+    key = OpenKey(root_key, test_key_name, 0, KEY_ALL_ACCESS)
+    sub_key = OpenKey(key, "sub_key", 0, KEY_ALL_ACCESS)
+    # It is not necessary to delete the values before deleting
+    # the key (although subkeys must not exist).  We delete them
+    # manually just to prove we can :-)
+    for value_name, value_data, value_type in test_data:
+        DeleteValue(sub_key, value_name)
+
+    nkeys, nvalues, since_mod = QueryInfoKey(sub_key)
+    assert nkeys==0 and nvalues==0, "subkey not empty before delete"
+    sub_key.Close()
+    DeleteKey(key, "sub_key")
+
+    try:
+        # Shouldnt be able to delete it twice!
+        DeleteKey(key, "sub_key")
+        assert 0, "Deleting the key twice succeeded"
+    except EnvironmentError:
+        pass
+    key.Close()
+    DeleteKey(root_key, test_key_name)
+    # Opening should now fail!
+    try:
+        key = OpenKey(root_key, test_key_name)
+        assert 0, "Could open the non-existent key"
+    except WindowsError: # Use this error name this time
+        pass
+
+def TestAll(root_key):
+    WriteTestData(root_key)
+    ReadTestData(root_key)
+    DeleteTestData(root_key)
+
+# Test on my local machine.
+TestAll(HKEY_CURRENT_USER)
+print "Local registry tests worked"
+try:
+    remote_name = sys.argv[sys.argv.index("--remote")+1]
+except (IndexError, ValueError):
+    remote_name = None
+
+if remote_name is not None:
+    try:
+        remote_key = ConnectRegistry(remote_name, HKEY_CURRENT_USER)
+    except EnvironmentError, exc:
+        print "Could not connect to the remote machine -", exc.strerror
+        remote_key = None
+    if remote_key is not None:
+        TestAll(remote_key)
+        print "Remote registry tests worked"
+else:
+    print "Remote registry calls can be tested using",
+    print "'test_winreg.py --remote \\\\machine_name'"
+