"""
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'
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.
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().
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):
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
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
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:
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:
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:
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"