Merged revisions 77841 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r77841 | ezio.melotti | 2010-01-30 09:22:54 +0200 (Sat, 30 Jan 2010) | 1 line

  #7092: silence py3k warnings for deprecated modules
........
diff --git a/Lib/test/test_anydbm.py b/Lib/test/test_anydbm.py
index 0cdc2c3..a01dd0b 100644
--- a/Lib/test/test_anydbm.py
+++ b/Lib/test/test_anydbm.py
@@ -5,12 +5,14 @@
 
 import os
 import unittest
-import anydbm
 import glob
 from test import test_support
 
 _fname = test_support.TESTFN
 
+# Silence Py3k warning
+anydbm = test_support.import_module('anydbm', deprecated=True)
+
 def _delete_files():
     # we don't know the precise name the underlying database uses
     # so we use glob to locate all names
diff --git a/Lib/test/test_bsddb.py b/Lib/test/test_bsddb.py
index f6e6ad0..fa88f565 100755
--- a/Lib/test/test_bsddb.py
+++ b/Lib/test/test_bsddb.py
@@ -9,6 +9,14 @@
 import unittest
 from test import test_support
 
+# Skip test if _bsddb wasn't built.
+test_support.import_module('_bsddb')
+
+bsddb = test_support.import_module('bsddb', deprecated=True)
+# Just so we know it's imported:
+test_support.import_module('dbhash', deprecated=True)
+
+
 class TestBSDDB(unittest.TestCase):
     openflag = 'c'
 
diff --git a/Lib/test/test_commands.py b/Lib/test/test_commands.py
index d899d66..dc1a598 100644
--- a/Lib/test/test_commands.py
+++ b/Lib/test/test_commands.py
@@ -9,7 +9,10 @@
 warnings.filterwarnings('ignore', r".*commands.getstatus.. is deprecated",
                         DeprecationWarning)
 
-from test.test_support import TestSkipped, run_unittest, reap_children
+from test.test_support import TestSkipped, run_unittest, reap_children, import_module
+
+# Silence Py3k warning
+import_module('commands', deprecated=True)
 from commands import *
 
 # The module says:
diff --git a/Lib/test/test_hotshot.py b/Lib/test/test_hotshot.py
index bc499bb..8a89b37 100644
--- a/Lib/test/test_hotshot.py
+++ b/Lib/test/test_hotshot.py
@@ -1,5 +1,3 @@
-import hotshot
-import hotshot.log
 import os
 import pprint
 import unittest
@@ -9,6 +7,8 @@
 
 from test import test_support
 
+# Silence Py3k warning
+hotshot = test_support.import_module('hotshot', deprecated=True)
 from hotshot.log import ENTER, EXIT, LINE
 from hotshot import stats
 
diff --git a/Lib/test/test_linuxaudiodev.py b/Lib/test/test_linuxaudiodev.py
index 813df6f..e406be6 100644
--- a/Lib/test/test_linuxaudiodev.py
+++ b/Lib/test/test_linuxaudiodev.py
@@ -4,12 +4,13 @@
 from test.test_support import findfile, TestSkipped, run_unittest
 
 import errno
-linuxaudiodev = test_support.import_module('linuxaudiodev', deprecated=True)
 import sys
-import sunaudio
 import audioop
 import unittest
 
+linuxaudiodev = test_support.import_module('linuxaudiodev', deprecated=True)
+sunaudio = test_support.import_module('sunaudio', deprecated=True)
+
 SND_FORMAT_MULAW_8 = 1
 
 class LinuxAudioDevTests(unittest.TestCase):
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index 714bf25..44e3ca8 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -5,7 +5,6 @@
 import socket
 import email
 import email.message
-import rfc822
 import re
 import StringIO
 from test import test_support
@@ -17,6 +16,8 @@
 except ImportError:
     pass
 
+# Silence Py3k warning
+rfc822 = test_support.import_module('rfc822', deprecated=True)
 
 class TestBase(unittest.TestCase):
 
diff --git a/Lib/test/test_multifile.py b/Lib/test/test_multifile.py
index daf7dde..043075b 100644
--- a/Lib/test/test_multifile.py
+++ b/Lib/test/test_multifile.py
@@ -1,5 +1,5 @@
 from test import test_support
-import mimetools
+mimetools = test_support.import_module('mimetools', deprecated=True)
 multifile = test_support.import_module('multifile', deprecated=True)
 import cStringIO
 
diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py
index 5fbe75d..6a97137 100644
--- a/Lib/test/test_pyclbr.py
+++ b/Lib/test/test_pyclbr.py
@@ -2,7 +2,7 @@
    Test cases for pyclbr.py
    Nick Mathewson
 '''
-from test.test_support import run_unittest
+from test.test_support import run_unittest, import_module
 import sys
 from types import ClassType, FunctionType, MethodType, BuiltinFunctionType
 import pyclbr
@@ -11,8 +11,10 @@
 StaticMethodType = type(staticmethod(lambda: None))
 ClassMethodType = type(classmethod(lambda c: None))
 
-# This next line triggers an error on old versions of pyclbr.
+# Silence Py3k warning
+import_module('commands', deprecated=True)
 
+# This next line triggers an error on old versions of pyclbr.
 from commands import getstatus
 
 # Here we test the python class browser code.
@@ -40,16 +42,16 @@
 
 
     def assertHaskey(self, obj, key, ignore):
-        ''' succeed iff obj.has_key(key) or key in ignore. '''
+        ''' succeed iff key in obj or key in ignore. '''
         if key in ignore: return
-        if not obj.has_key(key):
-            print >>sys.stderr, "***",key
-        self.failUnless(obj.has_key(key))
+        if key not in obj:
+            print >>sys.stderr, "***", key
+        self.assertTrue(key in obj)
 
     def assertEqualsOrIgnored(self, a, b, ignore):
         ''' succeed iff a == b or a in ignore or b in ignore '''
         if a not in ignore and b not in ignore:
-            self.assertEquals(a, b)
+            self.assertEqual(a, b)
 
     def checkModule(self, moduleName, module=None, ignore=()):
         ''' succeed iff pyclbr.readmodule_ex(modulename) corresponds
@@ -149,7 +151,9 @@
     def test_easy(self):
         self.checkModule('pyclbr')
         self.checkModule('doctest')
-        self.checkModule('rfc822')
+        # Silence Py3k warning
+        rfc822 = import_module('rfc822', deprecated=True)
+        self.checkModule('rfc822', rfc822)
         self.checkModule('difflib')
 
     def test_decorators(self):
diff --git a/Lib/test/test_shelve.py b/Lib/test/test_shelve.py
index f03457f..df56625 100644
--- a/Lib/test/test_shelve.py
+++ b/Lib/test/test_shelve.py
@@ -4,6 +4,8 @@
 import glob
 from test import test_support
 
+test_support.import_module('anydbm', deprecated=True)
+
 class TestCase(unittest.TestCase):
 
     fn = "shelftemp" + os.extsep + "db"
diff --git a/Lib/test/test_transformer.py b/Lib/test/test_transformer.py
index 909cda5..6590937 100644
--- a/Lib/test/test_transformer.py
+++ b/Lib/test/test_transformer.py
@@ -1,5 +1,8 @@
 import unittest
 from test import test_support
+
+# Silence Py3k warning
+test_support.import_module('compiler', deprecated=True)
 from compiler import transformer, ast
 from compiler import compile
 
diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py
index 8ae01b6..564343a 100644
--- a/Lib/test/test_urllib2_localnet.py
+++ b/Lib/test/test_urllib2_localnet.py
@@ -1,6 +1,5 @@
 #!/usr/bin/env python
 
-import mimetools
 import threading
 import urlparse
 import urllib2
@@ -8,6 +7,7 @@
 import unittest
 import hashlib
 from test import test_support
+mimetools = test_support.import_module('mimetools', deprecated=True)
 
 # Loopback http server infrastructure
 
@@ -154,13 +154,13 @@
         if len(self._users) == 0:
             return True
 
-        if not request_handler.headers.has_key('Proxy-Authorization'):
+        if 'Proxy-Authorization' not in request_handler.headers:
             return self._return_auth_challenge(request_handler)
         else:
             auth_dict = self._create_auth_dict(
                 request_handler.headers['Proxy-Authorization']
                 )
-            if self._users.has_key(auth_dict["username"]):
+            if auth_dict["username"] in self._users:
                 password = self._users[ auth_dict["username"] ]
             else:
                 return self._return_auth_challenge(request_handler)
diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py
index b92bfc9..dc46c21 100644
--- a/Lib/test/test_urllibnet.py
+++ b/Lib/test/test_urllibnet.py
@@ -7,7 +7,7 @@
 import urllib
 import sys
 import os
-import mimetools
+mimetools = test_support.import_module("mimetools", deprecated=True)
 import time
 
 
diff --git a/Lib/test/test_whichdb.py b/Lib/test/test_whichdb.py
index 1ce816f..5a8d630 100644
--- a/Lib/test/test_whichdb.py
+++ b/Lib/test/test_whichdb.py
@@ -7,11 +7,13 @@
 import test.test_support
 import unittest
 import whichdb
-import anydbm
 import glob
 
 _fname = test.test_support.TESTFN
 
+# Silence Py3k warning
+anydbm = test.test_support.import_module('anydbm', deprecated=True)
+
 def _delete_files():
     # we don't know the precise name the underlying database uses
     # so we use glob to locate all names
@@ -37,8 +39,9 @@
     # we define a new test method for each
     # candidate database module.
     try:
-        mod = __import__(name)
-    except ImportError:
+        # Silence Py3k warning
+        mod = test.test_support.import_module(name, deprecated=True)
+    except test.test_support.TestSkipped:
         continue
 
     def test_whichdb_name(self, name=name, mod=mod):
diff --git a/Lib/test/test_xmllib.py b/Lib/test/test_xmllib.py
index 0780bc9..68b883a 100644
--- a/Lib/test/test_xmllib.py
+++ b/Lib/test/test_xmllib.py
@@ -15,13 +15,10 @@
 
 nsdoc = "<foo xmlns='URI' attr='val'/>"
 
-import warnings
-warnings.filterwarnings("ignore", ".* xmllib .* obsolete.*",
-                        DeprecationWarning, r'xmllib$')
-
 from test import test_support
 import unittest
-import xmllib
+# Silence Py3k warning
+xmllib = test_support.import_module('xmllib', deprecated=True)
 
 class XMLParserTestCase(unittest.TestCase):