mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
#7092: silence py3k warnings for deprecated modules
This commit is contained in:
parent
75d3fb1ebb
commit
a2d4653740
14 changed files with 47 additions and 30 deletions
|
@ -5,12 +5,14 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
import anydbm
|
|
||||||
import glob
|
import glob
|
||||||
from test import test_support
|
from test import test_support
|
||||||
|
|
||||||
_fname = test_support.TESTFN
|
_fname = test_support.TESTFN
|
||||||
|
|
||||||
|
# Silence Py3k warning
|
||||||
|
anydbm = test_support.import_module('anydbm', deprecated=True)
|
||||||
|
|
||||||
def _delete_files():
|
def _delete_files():
|
||||||
# we don't know the precise name the underlying database uses
|
# we don't know the precise name the underlying database uses
|
||||||
# so we use glob to locate all names
|
# so we use glob to locate all names
|
||||||
|
|
|
@ -10,8 +10,9 @@ from test import test_support
|
||||||
# Skip test if _bsddb wasn't built.
|
# Skip test if _bsddb wasn't built.
|
||||||
test_support.import_module('_bsddb')
|
test_support.import_module('_bsddb')
|
||||||
|
|
||||||
import bsddb
|
bsddb = test_support.import_module('bsddb', deprecated=True)
|
||||||
import dbhash # Just so we know it's imported
|
# Just so we know it's imported:
|
||||||
|
test_support.import_module('dbhash', deprecated=True)
|
||||||
|
|
||||||
|
|
||||||
class TestBSDDB(unittest.TestCase):
|
class TestBSDDB(unittest.TestCase):
|
||||||
|
|
|
@ -9,7 +9,10 @@ import warnings
|
||||||
warnings.filterwarnings('ignore', r".*commands.getstatus.. is deprecated",
|
warnings.filterwarnings('ignore', r".*commands.getstatus.. is deprecated",
|
||||||
DeprecationWarning)
|
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 *
|
from commands import *
|
||||||
|
|
||||||
# The module says:
|
# The module says:
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import hotshot
|
|
||||||
import hotshot.log
|
|
||||||
import os
|
import os
|
||||||
import pprint
|
import pprint
|
||||||
import unittest
|
import unittest
|
||||||
|
@ -9,6 +7,8 @@ import gc
|
||||||
|
|
||||||
from test import test_support
|
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.log import ENTER, EXIT, LINE
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,13 @@ test_support.requires('audio')
|
||||||
from test.test_support import findfile, run_unittest
|
from test.test_support import findfile, run_unittest
|
||||||
|
|
||||||
import errno
|
import errno
|
||||||
linuxaudiodev = test_support.import_module('linuxaudiodev', deprecated=True)
|
|
||||||
import sys
|
import sys
|
||||||
import sunaudio
|
|
||||||
import audioop
|
import audioop
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
linuxaudiodev = test_support.import_module('linuxaudiodev', deprecated=True)
|
||||||
|
sunaudio = test_support.import_module('sunaudio', deprecated=True)
|
||||||
|
|
||||||
SND_FORMAT_MULAW_8 = 1
|
SND_FORMAT_MULAW_8 = 1
|
||||||
|
|
||||||
class LinuxAudioDevTests(unittest.TestCase):
|
class LinuxAudioDevTests(unittest.TestCase):
|
||||||
|
|
|
@ -5,7 +5,6 @@ import stat
|
||||||
import socket
|
import socket
|
||||||
import email
|
import email
|
||||||
import email.message
|
import email.message
|
||||||
import rfc822
|
|
||||||
import re
|
import re
|
||||||
import StringIO
|
import StringIO
|
||||||
from test import test_support
|
from test import test_support
|
||||||
|
@ -17,6 +16,8 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Silence Py3k warning
|
||||||
|
rfc822 = test_support.import_module('rfc822', deprecated=True)
|
||||||
|
|
||||||
class TestBase(unittest.TestCase):
|
class TestBase(unittest.TestCase):
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from test import test_support
|
from test import test_support
|
||||||
import mimetools
|
mimetools = test_support.import_module('mimetools', deprecated=True)
|
||||||
multifile = test_support.import_module('multifile', deprecated=True)
|
multifile = test_support.import_module('multifile', deprecated=True)
|
||||||
import cStringIO
|
import cStringIO
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Test cases for pyclbr.py
|
Test cases for pyclbr.py
|
||||||
Nick Mathewson
|
Nick Mathewson
|
||||||
'''
|
'''
|
||||||
from test.test_support import run_unittest
|
from test.test_support import run_unittest, import_module
|
||||||
import sys
|
import sys
|
||||||
from types import ClassType, FunctionType, MethodType, BuiltinFunctionType
|
from types import ClassType, FunctionType, MethodType, BuiltinFunctionType
|
||||||
import pyclbr
|
import pyclbr
|
||||||
|
@ -11,8 +11,10 @@ from unittest import TestCase
|
||||||
StaticMethodType = type(staticmethod(lambda: None))
|
StaticMethodType = type(staticmethod(lambda: None))
|
||||||
ClassMethodType = type(classmethod(lambda c: 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
|
from commands import getstatus
|
||||||
|
|
||||||
# Here we test the python class browser code.
|
# Here we test the python class browser code.
|
||||||
|
@ -40,16 +42,16 @@ class PyclbrTest(TestCase):
|
||||||
|
|
||||||
|
|
||||||
def assertHaskey(self, obj, key, ignore):
|
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 key in ignore: return
|
||||||
if not obj.has_key(key):
|
if key not in obj:
|
||||||
print >>sys.stderr, "***",key
|
print >>sys.stderr, "***", key
|
||||||
self.assertTrue(obj.has_key(key))
|
self.assertIn(key, obj)
|
||||||
|
|
||||||
def assertEqualsOrIgnored(self, a, b, ignore):
|
def assertEqualsOrIgnored(self, a, b, ignore):
|
||||||
''' succeed iff a == b or a in ignore or b in ignore '''
|
''' succeed iff a == b or a in ignore or b in ignore '''
|
||||||
if a not in ignore and b not 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=()):
|
def checkModule(self, moduleName, module=None, ignore=()):
|
||||||
''' succeed iff pyclbr.readmodule_ex(modulename) corresponds
|
''' succeed iff pyclbr.readmodule_ex(modulename) corresponds
|
||||||
|
@ -149,7 +151,9 @@ class PyclbrTest(TestCase):
|
||||||
def test_easy(self):
|
def test_easy(self):
|
||||||
self.checkModule('pyclbr')
|
self.checkModule('pyclbr')
|
||||||
self.checkModule('doctest', ignore=("DocTestCase",))
|
self.checkModule('doctest', ignore=("DocTestCase",))
|
||||||
self.checkModule('rfc822')
|
# Silence Py3k warning
|
||||||
|
rfc822 = import_module('rfc822', deprecated=True)
|
||||||
|
self.checkModule('rfc822', rfc822)
|
||||||
self.checkModule('difflib')
|
self.checkModule('difflib')
|
||||||
|
|
||||||
def test_decorators(self):
|
def test_decorators(self):
|
||||||
|
|
|
@ -4,6 +4,8 @@ import shelve
|
||||||
import glob
|
import glob
|
||||||
from test import test_support
|
from test import test_support
|
||||||
|
|
||||||
|
test_support.import_module('anydbm', deprecated=True)
|
||||||
|
|
||||||
class TestCase(unittest.TestCase):
|
class TestCase(unittest.TestCase):
|
||||||
|
|
||||||
fn = "shelftemp" + os.extsep + "db"
|
fn = "shelftemp" + os.extsep + "db"
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
import unittest
|
import unittest
|
||||||
from test import test_support
|
from test import test_support
|
||||||
|
|
||||||
|
# Silence Py3k warning
|
||||||
|
test_support.import_module('compiler', deprecated=True)
|
||||||
from compiler import transformer, ast
|
from compiler import transformer, ast
|
||||||
from compiler import compile
|
from compiler import compile
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import mimetools
|
|
||||||
import threading
|
import threading
|
||||||
import urlparse
|
import urlparse
|
||||||
import urllib2
|
import urllib2
|
||||||
|
@ -8,6 +7,7 @@ import BaseHTTPServer
|
||||||
import unittest
|
import unittest
|
||||||
import hashlib
|
import hashlib
|
||||||
from test import test_support
|
from test import test_support
|
||||||
|
mimetools = test_support.import_module('mimetools', deprecated=True)
|
||||||
|
|
||||||
# Loopback http server infrastructure
|
# Loopback http server infrastructure
|
||||||
|
|
||||||
|
@ -154,13 +154,13 @@ class DigestAuthHandler:
|
||||||
if len(self._users) == 0:
|
if len(self._users) == 0:
|
||||||
return True
|
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)
|
return self._return_auth_challenge(request_handler)
|
||||||
else:
|
else:
|
||||||
auth_dict = self._create_auth_dict(
|
auth_dict = self._create_auth_dict(
|
||||||
request_handler.headers['Proxy-Authorization']
|
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"] ]
|
password = self._users[ auth_dict["username"] ]
|
||||||
else:
|
else:
|
||||||
return self._return_auth_challenge(request_handler)
|
return self._return_auth_challenge(request_handler)
|
||||||
|
|
|
@ -7,7 +7,7 @@ import socket
|
||||||
import urllib
|
import urllib
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import mimetools
|
mimetools = test_support.import_module("mimetools", deprecated=True)
|
||||||
|
|
||||||
|
|
||||||
def _open_with_retry(func, host, *args, **kwargs):
|
def _open_with_retry(func, host, *args, **kwargs):
|
||||||
|
|
|
@ -7,11 +7,13 @@ import os
|
||||||
import test.test_support
|
import test.test_support
|
||||||
import unittest
|
import unittest
|
||||||
import whichdb
|
import whichdb
|
||||||
import anydbm
|
|
||||||
import glob
|
import glob
|
||||||
|
|
||||||
_fname = test.test_support.TESTFN
|
_fname = test.test_support.TESTFN
|
||||||
|
|
||||||
|
# Silence Py3k warning
|
||||||
|
anydbm = test.test_support.import_module('anydbm', deprecated=True)
|
||||||
|
|
||||||
def _delete_files():
|
def _delete_files():
|
||||||
# we don't know the precise name the underlying database uses
|
# we don't know the precise name the underlying database uses
|
||||||
# so we use glob to locate all names
|
# 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
|
# we define a new test method for each
|
||||||
# candidate database module.
|
# candidate database module.
|
||||||
try:
|
try:
|
||||||
mod = __import__(name)
|
# Silence Py3k warning
|
||||||
except ImportError:
|
mod = test.test_support.import_module(name, deprecated=True)
|
||||||
|
except unittest.SkipTest:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
def test_whichdb_name(self, name=name, mod=mod):
|
def test_whichdb_name(self, name=name, mod=mod):
|
||||||
|
|
|
@ -15,13 +15,10 @@ testdoc = """\
|
||||||
|
|
||||||
nsdoc = "<foo xmlns='URI' attr='val'/>"
|
nsdoc = "<foo xmlns='URI' attr='val'/>"
|
||||||
|
|
||||||
import warnings
|
|
||||||
warnings.filterwarnings("ignore", ".* xmllib .* obsolete.*",
|
|
||||||
DeprecationWarning, r'xmllib$')
|
|
||||||
|
|
||||||
from test import test_support
|
from test import test_support
|
||||||
import unittest
|
import unittest
|
||||||
import xmllib
|
# Silence Py3k warning
|
||||||
|
xmllib = test_support.import_module('xmllib', deprecated=True)
|
||||||
|
|
||||||
class XMLParserTestCase(unittest.TestCase):
|
class XMLParserTestCase(unittest.TestCase):
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue