]> granicus.if.org Git - python/commitdiff
#7092: silence py3k warnings for deprecated modules
authorEzio Melotti <ezio.melotti@gmail.com>
Sat, 30 Jan 2010 07:22:54 +0000 (07:22 +0000)
committerEzio Melotti <ezio.melotti@gmail.com>
Sat, 30 Jan 2010 07:22:54 +0000 (07:22 +0000)
14 files changed:
Lib/test/test_anydbm.py
Lib/test/test_bsddb.py
Lib/test/test_commands.py
Lib/test/test_hotshot.py
Lib/test/test_linuxaudiodev.py
Lib/test/test_mailbox.py
Lib/test/test_multifile.py
Lib/test/test_pyclbr.py
Lib/test/test_shelve.py
Lib/test/test_transformer.py
Lib/test/test_urllib2_localnet.py
Lib/test/test_urllibnet.py
Lib/test/test_whichdb.py
Lib/test/test_xmllib.py

index 0cdc2c321d0c911cab464bf4e54e0ab9f0af9118..a01dd0bd9fc0b92f920660de2103763e7d2a60c5 100644 (file)
@@ -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
index 5dda50c1a90ea0eae7ad857118e7030ef387170e..a5fa494401f3667d8f16b4e2451cc6405bf4c9ad 100755 (executable)
@@ -10,8 +10,9 @@ 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
+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):
index fcfa616cb74e87b1dbbb261ccdeaea2343b2b97d..27b6c3d56c2c0b8d00983b106c839e730069a09a 100644 (file)
@@ -9,7 +9,10 @@ import warnings
 warnings.filterwarnings('ignore', r".*commands.getstatus.. is deprecated",
                         DeprecationWarning)
 
-from test.test_support import run_unittest, reap_children
+from test.test_support import run_unittest, reap_children, import_module
+
+# Silence Py3k warning
+import_module('commands', deprecated=True)
 from commands import *
 
 # The module says:
index 38a8dddb6a6ce73565ce3d9a1baf8f5f6bb354da..c6dae363cdcb90ed29642e7dacb90ebc9b873bf5 100644 (file)
@@ -1,5 +1,3 @@
-import hotshot
-import hotshot.log
 import os
 import pprint
 import unittest
@@ -9,6 +7,8 @@ import gc
 
 from test import test_support
 
+# Silence Py3k warning
+hotshot = test_support.import_module('hotshot', deprecated=True)
 from hotshot.log import ENTER, EXIT, LINE
 
 
index 71d0633337937adaa7969e0d034dbc0011505c09..3772a58e94d1371b8312629b416484c71179f963 100644 (file)
@@ -4,12 +4,13 @@ test_support.requires('audio')
 from test.test_support import findfile, 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):
index 548850ad1ea32e3d4b4c83b590c1986bfd446029..c88af0613722cc4ae5a2667d59e250e0be748168 100644 (file)
@@ -5,7 +5,6 @@ import stat
 import socket
 import email
 import email.message
-import rfc822
 import re
 import StringIO
 from test import test_support
@@ -17,6 +16,8 @@ try:
 except ImportError:
     pass
 
+# Silence Py3k warning
+rfc822 = test_support.import_module('rfc822', deprecated=True)
 
 class TestBase(unittest.TestCase):
 
index daf7ddefd8c260f9b4738329e7e1fd8adf55d94a..043075b72f2b04bdfacaa05c93bf6cd6ce63e1bf 100644 (file)
@@ -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
 
index 8d22fc2602a1a2b2c903c9695816f35306da304b..fda76d4611bef5fc835d570f1ad24de96bded310 100644 (file)
@@ -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 @@ from unittest import TestCase
 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 @@ class PyclbrTest(TestCase):
 
 
     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.assertTrue(obj.has_key(key))
+        if key not in obj:
+            print >>sys.stderr, "***", key
+        self.assertIn(key, 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 @@ class PyclbrTest(TestCase):
     def test_easy(self):
         self.checkModule('pyclbr')
         self.checkModule('doctest', ignore=("DocTestCase",))
-        self.checkModule('rfc822')
+        # Silence Py3k warning
+        rfc822 = import_module('rfc822', deprecated=True)
+        self.checkModule('rfc822', rfc822)
         self.checkModule('difflib')
 
     def test_decorators(self):
index ffcc98da56e367c79f74d7d296be572b2427098c..3b20281a02b9b9e660889287607b35f64469d95d 100644 (file)
@@ -4,6 +4,8 @@ import shelve
 import glob
 from test import test_support
 
+test_support.import_module('anydbm', deprecated=True)
+
 class TestCase(unittest.TestCase):
 
     fn = "shelftemp" + os.extsep + "db"
index b392055255495b3726d09861b94b8c8768a2e31c..1891ac486e6f0a86444279929504e538f5718fa2 100644 (file)
@@ -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
 
index 5d65b6ec974942c62d4762c8302df4b2e97f68f9..e2c17891aa0b6a4df7a571a771e7f002580bff3f 100644 (file)
@@ -1,6 +1,5 @@
 #!/usr/bin/env python
 
-import mimetools
 import threading
 import urlparse
 import urllib2
@@ -8,6 +7,7 @@ import BaseHTTPServer
 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 @@ class DigestAuthHandler:
         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)
index 39286f9c9144e125f3b10ca8943da2a5d70a7afb..77b544552dc7844569437782c7c2e4c4dc5caf00 100644 (file)
@@ -7,7 +7,7 @@ import socket
 import urllib
 import sys
 import os
-import mimetools
+mimetools = test_support.import_module("mimetools", deprecated=True)
 
 
 def _open_with_retry(func, host, *args, **kwargs):
index 1ce816f866fe2d9a21305c7fbc55e25bd15e0be0..427e323f4943e638d116f16399bb7980ea39c77d 100644 (file)
@@ -7,11 +7,13 @@ import os
 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 @@ for name in anydbm._names:
     # 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 unittest.SkipTest:
         continue
 
     def test_whichdb_name(self, name=name, mod=mod):
index 0780bc95f3d14281a7cb2f1dd8e804eb8788233d..68b883a0e50f31403353b35220bdf3493dd7b13b 100644 (file)
@@ -15,13 +15,10 @@ testdoc = """\
 
 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):