[Python-checkins] CVS: python/nondist/sandbox/typecheck/test testaddchecks.py,NONE,1.1 testchecks.py,NONE,1.1 testall.py,1.1,1.2

Paul Prescod prescod@users.sourceforge.net
Tue, 20 Mar 2001 13:02:37 -0800


Update of /cvsroot/python/python/nondist/sandbox/typecheck/test
In directory usw-pr-cvs1:/tmp/cvs-serv2837/test

Modified Files:
	testall.py 
Added Files:
	testaddchecks.py testchecks.py 
Log Message:
Added strict mode. Strict mode is off by default.

This is useful because it means that mistaken  declarations will 
not crash Python. That's important while we work out the "right" 
set of declarations. 


--- NEW FILE: testaddchecks.py ---
import addchecks
import sys, glob, os, shutil

mydir = os.path.split(sys.argv[0])[0]
libdir = os.path.split(glob.__file__)[0]
filenames = glob.glob(os.path.join(mydir, "..", "lib", "*.pyt"))

for name in filenames:
    shortname = os.path.split(name)[1]
    target = os.path.join(libdir, shortname)
    shutil.copy(name, target)
    assert target.endswith(".pyt")
    module = target[0:-1] # chop off 't' from '.pyt'
    addchecks.addchecks(module)    




--- NEW FILE: testchecks.py ---
# now test if the addition worked
import typecheck, os, sys, glob

mydir = os.path.split(sys.argv[0])[0]
libdir = os.path.split(glob.__file__)[0]

print "Testing SRE"
import sre
sre.match('abc', 'def')
try:
    sre.match(None, "def")
except typecheck.InterfaceError, e:
    print "Expect error to follow!"
    print e

try:
    sre.match("def", None)
except typecheck.InterfaceError, e:
    print "Expect error to follow!"
    print e

os.system(os.path.join(libdir, "test", "test_sre.py"))


import xmllib

print "Testing xmllib"

xmllib.XMLParser().feed("<?xml version='1.0'?>")

try:
    xmllib.XMLParser().feed(1)
    assert 0, "Should not get to this point"
except typecheck.InterfaceError, e:
    print "Expect error to follow!"
    print e

os.system(os.path.join(libdir, "test", "test_xmllib.py"))

print "Success!"

Index: testall.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/typecheck/test/testall.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** testall.py	2001/03/20 03:01:01	1.1
--- testall.py	2001/03/20 21:02:35	1.2
***************
*** 1,55 ****
! import sys, glob, os, shutil
  import addchecks
  import typecheck
  
  mydir = os.path.split(sys.argv[0])[0]
! libdir = os.path.split(glob.__file__)[0]
! filenames = glob.glob(os.path.join(mydir, "..", "lib", "*.pyt"))
  
! for name in filenames:
!     shortname = os.path.split(name)[1]
!     target = os.path.join(libdir, shortname)
!     shutil.copy(name, target)
!     assert target.endswith(".pyt")
!     module = target[0:-1] # chop off 't' from '.pyt'
!     addchecks.addchecks(module)    
  
  
- 
- import sre
- print "Testing SRE"
- sre.match('abc', 'def')
- 
- try:
-     sre.match(None, "def")
- except typecheck.InterfaceError, e:
-     print "Expect error to follow!"
-     print e
- 
- try:
-     sre.match("def", None)
- except typecheck.InterfaceError, e:
-     print "Expect error to follow!"
-     print e
- 
- os.system(os.path.join(libdir, "test", "test_sre.py"))
- 
- 
- 
- 
- import xmllib
- 
- print "Testing xmllib"
- 
- xmllib.XMLParser().feed("<?xml version='1.0'?>")
- 
- try:
-     xmllib.XMLParser().feed(1)
-     assert 0, "Should not get to this point"
- except typecheck.InterfaceError, e:
-     print "Expect error to follow!"
-     print e
- 
- os.system(os.path.join(libdir, "test", "test_xmllib.py"))
- 
- print "Success!"
--- 1,15 ----
! import sys, os
  import addchecks
  import typecheck
  
  mydir = os.path.split(sys.argv[0])[0]
! testaddchecks = os.path.join(mydir, "testaddchecks.py") 
! testchecks = os.path.join(mydir, "testchecks.py")
  
! # run this in optimized mode so that it does NOT use typechecking
! # otherwise a bug in the typechecking code could make it impossible to
! # install the fix to the typechecking code!
! os.system(sys.executable + " -O "+ testaddchecks)
! os.system(sys.executable + " " + testchecks)