]> granicus.if.org Git - python/commitdiff
A few more test skips via import_module, and change import_module to
authorR. David Murray <rdmurray@bitdance.com>
Tue, 31 Mar 2009 18:32:17 +0000 (18:32 +0000)
committerR. David Murray <rdmurray@bitdance.com>
Tue, 31 Mar 2009 18:32:17 +0000 (18:32 +0000)
return the error message produced by importlib, so that if an import
in the package whose import is being wrapped is what failed the skip
message will contain the name of that module instead of the name of the
wrapped module.  Also fixed formatting of some previous comments.

Lib/test/test_bsddb.py
Lib/test/test_bsddb3.py
Lib/test/test_fcntl.py
Lib/test/test_scriptpackages.py
Lib/test/test_support.py
Lib/test/test_tcl.py
Lib/test/test_tk.py
Lib/test/test_ttk_guionly.py
Lib/test/test_ttk_textonly.py
Lib/test/test_winreg.py

index f6e6ad0b98ba15bc9657ceb8b0e1412f29445ffa..56dade4cc92de7a38cc10245cacdbfe55d21e082 100755 (executable)
@@ -4,11 +4,16 @@
 """
 import os, sys
 import copy
-import bsddb
-import dbhash # Just so we know it's imported
 import unittest
 from test import test_support
 
+# Skip test if _bsddb wasn't built.
+test_support.import_module('_bsddb')
+
+import bsddb
+import dbhash # Just so we know it's imported
+
+
 class TestBSDDB(unittest.TestCase):
     openflag = 'c'
 
index b290a6edb53ebb5c1518f75e61e95d660f9a676b..095c63206a80633aa7ce18a2d1c6722626035b2c 100644 (file)
@@ -10,8 +10,8 @@ import unittest
 from test.test_support import (requires, verbose, run_unittest, unlink, rmtree,
     import_module)
 
-#Skip test if bsddb cannot import _bsddb.
-import_module('bsddb')
+# Skip test if _bsddb module was not built.
+import_module('_bsddb')
 
 # When running as a script instead of within the regrtest framework, skip the
 # requires test, since it's obvious we want to run them.
index 8d416b6f378c62498204860de83a4cc1a485e9f0..2c5ac11b42c3b86c23c8ef6e490b469eafad76e8 100755 (executable)
@@ -3,12 +3,16 @@
 OS/2+EMX doesn't support the file locking operations.
 
 """
-import fcntl
 import os
 import struct
 import sys
 import unittest
-from test.test_support import verbose, TESTFN, unlink, run_unittest
+from test.test_support import (verbose, TESTFN, unlink, run_unittest,
+    import_module)
+
+# Skip test if no fnctl module.
+fcntl = import_module('fcntl')
+
 
 # TODO - Write tests for flock() and lockf().
 
index a3a1857d8502c631fa815838bf3d94aa2164dae5..7e02fa02f54351c20c77a42a1388d656abd07efc 100644 (file)
@@ -3,7 +3,8 @@
 import unittest
 from test import test_support
 
-aetools = test_support.import_module('aetools')
+# Skip this test if aetools does not exist.
+test_support.import_module('aetools')
 
 class TestScriptpackages(unittest.TestCase):
 
index 435333946dc45c691abe099f765bb252007b335f..3df1b27975d9a51e2e2dc5377360e2fa7afe302e 100644 (file)
@@ -51,8 +51,8 @@ def import_module(name, deprecated=False):
                                     DeprecationWarning)
         try:
             module = importlib.import_module(name)
-        except ImportError:
-            raise unittest.SkipTest("No module named " + name)
+        except ImportError, msg:
+            raise unittest.SkipTest(str(msg))
         else:
             return module
 
index 26e294ce1360d6a83982065bedb3f98f0db19777..0b05c54fe357bc684ef9210121c862d9110d5cb2 100644 (file)
@@ -2,8 +2,11 @@
 
 import unittest
 import os
-import _tkinter
 from test import test_support
+
+# Skip this test if the _tkinter module wasn't built.
+_tkinter = test_support.import_module('_tkinter')
+
 from Tkinter import Tcl
 from _tkinter import TclError
 
index 3ece3d9888f54773d315294988c2c7f973a317a7..df4715b6a0c3764dfa0bdfdcf9322151d57bb05c 100644 (file)
@@ -1,9 +1,13 @@
 import os
 import sys
 import unittest
-import Tkinter
 from test import test_support
 
+# Skip test if _tkinter wasn't built.
+test_support.import_module('_tkinter')
+
+import Tkinter
+
 try:
     Tkinter.Button()
 except Tkinter.TclError, msg:
index aa17c4772ecf5ddb51b0ac14db10feb71d62b859..379ebaefa3ffceb72904a6b61e778286691c63ae 100644 (file)
@@ -3,8 +3,10 @@ import sys
 import unittest
 from test import test_support
 
-ttk = test_support.import_module('ttk')
-#If ttk exists _tkinter must exist.
+# Skip this test if _tkinter wasn't built.
+test_support.import_module('_tkinter')
+
+import ttk
 from _tkinter import TclError
 
 try:
index e7d9c0078302dc0bc9fe6fb23d658cc44843f5b0..dde1b3551dce4d9baf27e7fb0ff5242ef14de90d 100644 (file)
@@ -2,6 +2,9 @@ import os
 import sys
 from test import test_support
 
+# Skip this test if _tkinter does not exist.
+test_support.import_module('_tkinter')
+
 this_dir = os.path.dirname(os.path.abspath(__file__))
 lib_tk_test = os.path.abspath(os.path.join(this_dir, '..', 'lib-tk', 'test'))
 if lib_tk_test not in sys.path:
index 1dbccc0027e4be6d732b9190ab411dd8237ef184..1eaa93047e79208cd3bcab862f163c080405ed07 100644 (file)
@@ -5,9 +5,9 @@ import os, sys
 import unittest
 from test import test_support
 
-#Do this first so test will be skipped if module doesn't exist
+# Do this first so test will be skipped if module doesn't exist
 test_support.import_module('_winreg')
-#Now import everything
+# Now import everything
 from _winreg import *
 
 test_key_name = "SOFTWARE\\Python Registry Test Key - Delete Me"