[Python-checkins] r55651 - in python/branches/bcannon-objcap/tests: README fail/builtin_execfile.py fail/builtin_open.py fail/file_constructor.py fail/import_unsafe_builtin.py fail/import_unsafe_extension.py

brett.cannon python-checkins at python.org
Tue May 29 21:16:05 CEST 2007


Author: brett.cannon
Date: Tue May 29 21:16:01 2007
New Revision: 55651

Modified:
   python/branches/bcannon-objcap/tests/README
   python/branches/bcannon-objcap/tests/fail/builtin_execfile.py
   python/branches/bcannon-objcap/tests/fail/builtin_open.py
   python/branches/bcannon-objcap/tests/fail/file_constructor.py
   python/branches/bcannon-objcap/tests/fail/import_unsafe_builtin.py
   python/branches/bcannon-objcap/tests/fail/import_unsafe_extension.py
Log:
Make all 'fail' tests have an 'else' clause for their try/except statements
that raise an exception if the expected exception is not caught.


Modified: python/branches/bcannon-objcap/tests/README
==============================================================================
--- python/branches/bcannon-objcap/tests/README	(original)
+++ python/branches/bcannon-objcap/tests/README	Tue May 29 21:16:01 2007
@@ -17,7 +17,8 @@
 
 * fail
     Tests that contain code that should not work in a secured interpreter.  All
-    insecure code should be contained with in proper try/except statements.
+    insecure code should be contained within proper try/except/else statements.
     The smallest amount of code required to test a security feature should be
-    within each try/except statement (of which there may be several within a
-    single file).
+    within each try/except/else statement (of which there may be several within
+    a single file).  Within the 'else' statement make sure to raise an
+    exception to flag that the expected exception was not raised.

Modified: python/branches/bcannon-objcap/tests/fail/builtin_execfile.py
==============================================================================
--- python/branches/bcannon-objcap/tests/fail/builtin_execfile.py	(original)
+++ python/branches/bcannon-objcap/tests/fail/builtin_execfile.py	Tue May 29 21:16:01 2007
@@ -3,14 +3,20 @@
     _ = execfile
 except NameError:
     pass
+else:
+    raise Exception
 
 try:
     import __builtin__
     __builtin__.execfile
 except AttributeError:
     pass
+else:
+    raise Exception
 
 try:
     __builtins__.execfile
 except AttributeError:
     pass
+else:
+    raise Exception

Modified: python/branches/bcannon-objcap/tests/fail/builtin_open.py
==============================================================================
--- python/branches/bcannon-objcap/tests/fail/builtin_open.py	(original)
+++ python/branches/bcannon-objcap/tests/fail/builtin_open.py	Tue May 29 21:16:01 2007
@@ -3,14 +3,20 @@
     _  = open
 except NameError:
     pass
+else:
+    raise Exception
 
 try:
     import __builtin__
     __builtin__.open
 except AttributeError:
     pass
+else:
+    raise Exception
 
 try:
     __builtins__.open
 except AttributeError:
     pass
+else:
+    raise Exception

Modified: python/branches/bcannon-objcap/tests/fail/file_constructor.py
==============================================================================
--- python/branches/bcannon-objcap/tests/fail/file_constructor.py	(original)
+++ python/branches/bcannon-objcap/tests/fail/file_constructor.py	Tue May 29 21:16:01 2007
@@ -3,3 +3,5 @@
     _ = file('README', 'r')
 except TypeError:
     pass
+else:
+    raise Exception

Modified: python/branches/bcannon-objcap/tests/fail/import_unsafe_builtin.py
==============================================================================
--- python/branches/bcannon-objcap/tests/fail/import_unsafe_builtin.py	(original)
+++ python/branches/bcannon-objcap/tests/fail/import_unsafe_builtin.py	Tue May 29 21:16:01 2007
@@ -3,3 +3,5 @@
     import sys
 except ImportError:
     pass
+else:
+    raise Exception

Modified: python/branches/bcannon-objcap/tests/fail/import_unsafe_extension.py
==============================================================================
--- python/branches/bcannon-objcap/tests/fail/import_unsafe_extension.py	(original)
+++ python/branches/bcannon-objcap/tests/fail/import_unsafe_extension.py	Tue May 29 21:16:01 2007
@@ -3,3 +3,5 @@
     import thread
 except ImportError:
     pass
+else:
+    raise Exception


More information about the Python-checkins mailing list