]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 77841 via svnmerge from
authorEzio Melotti <ezio.melotti@gmail.com>
Mon, 2 Aug 2010 01:33:30 +0000 (01:33 +0000)
committerEzio Melotti <ezio.melotti@gmail.com>
Mon, 2 Aug 2010 01:33:30 +0000 (01:33 +0000)
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
........

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 f6e6ad0b98ba15bc9657ceb8b0e1412f29445ffa..fa88f565b33c5dd236b62baa197e961ad420b9c5 100755 (executable)
@@ -9,6 +9,14 @@ 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')
+
+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'
 
index d899d6699e1d36e4d2ea6d434d58ec0e17b6e443..dc1a598b4185e810a93af00401361b68f52b4b83 100644 (file)
@@ -9,7 +9,10 @@ import warnings
 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:
index bc499bbfb37b96a1fd6fed5a091aa555d2cd36c7..8a89b373704589582da6a452a6adc3d67df30cf0 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
 from hotshot import stats
 
index 813df6fc73211e7933b20aa76289eecd3c237ce1..e406be6943c106e27a0d079da0c1ed7cdbcf8df5 100644 (file)
@@ -4,12 +4,13 @@ test_support.requires('audio')
 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):
index 714bf252ba81cb535995c56ec621915c40cfddf8..44e3ca824c37fb4852a9e8cf5271041326687088 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 5fbe75d660a388aaf6ff6369613b11dfd1929ca7..6a971379cb6a1cdd98999136b323abbd603dc999 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.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 @@ class PyclbrTest(TestCase):
     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):
index f03457f97828c2305798adda78ccdd1b3e9fe654..df56625a599843b0885c8ff45b19bf144a35b733 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 909cda51837cad3bbf574a62593bb8211bb6c47d..65909372e68cb1404d8fb2c1a16f774e899ba975 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 8ae01b684ae06c5ca4701edb0bd5670334b7d411..564343ab4f98f36eaee4b97b116999d803a0c851 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 b92bfc9c69f8866dba199e025ac2ce6f274cf4bd..dc46c210d2eac9a89349be4c72382cbe6b742c6e 100644 (file)
@@ -7,7 +7,7 @@ import socket
 import urllib
 import sys
 import os
-import mimetools
+mimetools = test_support.import_module("mimetools", deprecated=True)
 import time
 
 
index 1ce816f866fe2d9a21305c7fbc55e25bd15e0be0..5a8d6305ef1af362bb0b3fe779da83f7256dbebe 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 test.test_support.TestSkipped:
         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):