mirror of https://github.com/python/cpython
fix test_py3kwarns
The fact that this was failing and went unnoticed so long seems like a good argument for being able to enable and disble py3kwarnings through Python.
This commit is contained in:
parent
2ee623b710
commit
a6864e0d9f
|
@ -6,7 +6,8 @@ import rfc822
|
|||
import tempfile
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("in 3.x, mimetools has been removed in favor of the email package")
|
||||
warnpy3k("in 3.x, mimetools has been removed in favor of the email package",
|
||||
stacklevel=2)
|
||||
|
||||
__all__ = ["Message","choose_boundary","encode","decode","copyliteral",
|
||||
"copybinary"]
|
||||
|
|
|
@ -2,7 +2,7 @@ QSIZE = 100000
|
|||
error='Audio_mac.error'
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the Play_Audio_mac module is removed.")
|
||||
warnpy3k("In 3.x, the Play_Audio_mac module is removed.", stacklevel=2)
|
||||
|
||||
class Play_Audio_mac:
|
||||
|
||||
|
|
|
@ -4,4 +4,4 @@ warnings.filterwarnings("ignore", "", FutureWarning, ".*Controls")
|
|||
warnings.filterwarnings("ignore", "", FutureWarning, ".*MacTextEditor")
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, Carbon is removed.")
|
||||
warnpy3k("In 3.x, Carbon is removed.", stacklevel=2)
|
||||
|
|
|
@ -19,7 +19,7 @@ Based upon STDWIN dialogs with the same names and functions.
|
|||
"""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the EasyDialogs module is removed.")
|
||||
warnpy3k("In 3.x, the EasyDialogs module is removed.", stacklevel=2)
|
||||
|
||||
from Carbon.Dlg import GetNewDialog, SetDialogItemText, GetDialogItemText, ModalDialog
|
||||
from Carbon import Qd
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
DEBUG=0
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the FrameWork module is removed.")
|
||||
warnpy3k("In 3.x, the FrameWork module is removed.", stacklevel=2)
|
||||
|
||||
import MacOS
|
||||
import traceback
|
||||
|
|
|
@ -7,7 +7,7 @@ There are two classes:
|
|||
"""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the MiniAEFrame module is removed.")
|
||||
warnpy3k("In 3.x, the MiniAEFrame module is removed.", stacklevel=2)
|
||||
|
||||
import traceback
|
||||
import MacOS
|
||||
|
|
|
@ -7,7 +7,7 @@ J. Strout <joe@strout.net> February 1999"""
|
|||
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the PixMapWrapper module is removed.")
|
||||
warnpy3k("In 3.x, the PixMapWrapper module is removed.", stacklevel=2)
|
||||
|
||||
from Carbon import Qd
|
||||
from Carbon import QuickDraw
|
||||
|
|
|
@ -13,7 +13,7 @@ coerce(x, wanted_sample) coerces a python object to another python object
|
|||
#
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the aepack module is removed.")
|
||||
warnpy3k("In 3.x, the aepack module is removed.", stacklevel=2)
|
||||
|
||||
import struct
|
||||
import types
|
||||
|
|
|
@ -22,7 +22,7 @@ files: the pack stuff from aepack, the objects from aetypes.
|
|||
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the aetools module is removed.")
|
||||
warnpy3k("In 3.x, the aetools module is removed.", stacklevel=2)
|
||||
|
||||
from types import *
|
||||
from Carbon import AE
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""aetypes - Python objects representing various AE types."""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the aetypes module is removed.")
|
||||
warnpy3k("In 3.x, the aetypes module is removed.", stacklevel=2)
|
||||
|
||||
from Carbon.AppleEvents import *
|
||||
import struct
|
||||
|
|
|
@ -2,7 +2,7 @@ r"""Routines to decode AppleSingle files
|
|||
"""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the applesingle module is removed.")
|
||||
warnpy3k("In 3.x, the applesingle module is removed.", stacklevel=2)
|
||||
|
||||
import struct
|
||||
import sys
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the appletrawmain module is removed.")
|
||||
warnpy3k("In 3.x, the appletrawmain module is removed.", stacklevel=2)
|
||||
|
||||
import argvemulator
|
||||
import os
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# we are not running in a framework build.
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, appletrunner is removed.")
|
||||
warnpy3k("In 3.x, appletrunner is removed.", stacklevel=2)
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
|
|
@ -3,7 +3,7 @@ want unix-style arguments.
|
|||
"""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the argvemulator module is removed.")
|
||||
warnpy3k("In 3.x, the argvemulator module is removed.", stacklevel=2)
|
||||
|
||||
import sys
|
||||
import traceback
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import os
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the bgenlocations module is removed.")
|
||||
warnpy3k("In 3.x, the bgenlocations module is removed.", stacklevel=2)
|
||||
|
||||
Error = "bgenlocations.Error"
|
||||
#
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
"""tools for BuildApplet and BuildApplication"""
|
||||
|
||||
import warnings
|
||||
warnings.warn("the buildtools module is deprecated and is removed in 3.0",
|
||||
DeprecationWarning, 2)
|
||||
warnings.warnpy3k("the buildtools module is deprecated and is removed in 3.0",
|
||||
stacklevel=2)
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
|
|
@ -29,7 +29,7 @@ __all__ = ["BundleBuilder", "BundleBuilderError", "AppBuilder", "buildapp"]
|
|||
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the bundlebuilder module is removed.")
|
||||
warnpy3k("In 3.x, the bundlebuilder module is removed.", stacklevel=2)
|
||||
|
||||
import sys
|
||||
import os, errno, shutil
|
||||
|
|
|
@ -6,8 +6,8 @@ __version__ = "0.8b3"
|
|||
__author__ = "jvr"
|
||||
|
||||
import warnings
|
||||
warnings.warn("the cfmfile module is deprecated and is removed in 3,0",
|
||||
DeprecationWarning, 2)
|
||||
warnings.warnpy3k("the cfmfile module is deprecated and is removed in 3,0",
|
||||
stacklevel=2)
|
||||
|
||||
import Carbon.File
|
||||
import struct
|
||||
|
|
|
@ -16,7 +16,7 @@ Mostly written by erik@letterror.com
|
|||
"""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the findertools module is removed.")
|
||||
warnpy3k("In 3.x, the findertools module is removed.", stacklevel=2)
|
||||
|
||||
import Finder
|
||||
from Carbon import AppleEvents
|
||||
|
|
|
@ -7,7 +7,7 @@ Reading and understanding this code is left as an exercise to the reader.
|
|||
"""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the gensuitemodule module is removed.")
|
||||
warnpy3k("In 3.x, the gensuitemodule module is removed.", stacklevel=2)
|
||||
|
||||
import MacOS
|
||||
import EasyDialogs
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""IC wrapper module, based on Internet Config 1.3"""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the ic module is removed.")
|
||||
warnpy3k("In 3.x, the ic module is removed.", stacklevel=2)
|
||||
|
||||
import icglue
|
||||
import string
|
||||
|
|
|
@ -38,7 +38,7 @@ effect.
|
|||
"""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the icopen module is removed.")
|
||||
warnpy3k("In 3.x, the icopen module is removed.", stacklevel=2)
|
||||
|
||||
import __builtin__
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ Package generated from /Volumes/Sap/Applications (Mac OS 9)/Metrowerks CodeWarri
|
|||
"""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the CodeWarrior package is removed.")
|
||||
warnpy3k("In 3.x, the CodeWarrior package is removed.", stacklevel=2)
|
||||
|
||||
import aetools
|
||||
Error = aetools.Error
|
||||
|
|
|
@ -3,7 +3,7 @@ Package generated from /Applications/Internet Explorer.app
|
|||
"""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the Explorer module is removed.")
|
||||
warnpy3k("In 3.x, the Explorer module is removed.", stacklevel=2)
|
||||
|
||||
import aetools
|
||||
Error = aetools.Error
|
||||
|
|
|
@ -3,7 +3,7 @@ Package generated from /System/Library/CoreServices/Finder.app
|
|||
"""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the Finder package is removed.")
|
||||
warnpy3k("In 3.x, the Finder package is removed.", stacklevel=2)
|
||||
|
||||
import aetools
|
||||
Error = aetools.Error
|
||||
|
|
|
@ -3,7 +3,7 @@ Package generated from /Volumes/Sap/Applications (Mac OS 9)/Netscape Communicato
|
|||
"""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the Netscape package is removed.")
|
||||
warnpy3k("In 3.x, the Netscape package is removed.", stacklevel=2)
|
||||
|
||||
import aetools
|
||||
Error = aetools.Error
|
||||
|
|
|
@ -4,7 +4,7 @@ Resource aeut resid 0 Standard Event Suites for English
|
|||
"""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the StdSuites package is removed.")
|
||||
warnpy3k("In 3.x, the StdSuites package is removed.", stacklevel=2)
|
||||
|
||||
import aetools
|
||||
Error = aetools.Error
|
||||
|
|
|
@ -3,7 +3,7 @@ Package generated from /System/Library/CoreServices/System Events.app
|
|||
"""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the SystemEvents package is removed.")
|
||||
warnpy3k("In 3.x, the SystemEvents package is removed.", stacklevel=2)
|
||||
|
||||
import aetools
|
||||
Error = aetools.Error
|
||||
|
|
|
@ -3,7 +3,7 @@ Package generated from /Applications/Utilities/Terminal.app
|
|||
"""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the Terminal module is removed.")
|
||||
warnpy3k("In 3.x, the Terminal module is removed.", stacklevel=2)
|
||||
|
||||
import aetools
|
||||
Error = aetools.Error
|
||||
|
|
|
@ -6,7 +6,7 @@ in the Standard suite.
|
|||
"""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the _builtinSuites module is removed.")
|
||||
warnpy3k("In 3.x, the _builtinSuites module is removed.", stacklevel=2)
|
||||
|
||||
import aetools
|
||||
import builtin_Suite
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -coding=latin1-
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the macerrors module is removed.")
|
||||
warnpy3k("In 3.x, the macerrors module is removed.", stacklevel=2)
|
||||
|
||||
svTempDisable = -32768 #svTempDisable
|
||||
svDisabled = -32640 #Reserve range -32640 to -32768 for Apple temp disables.
|
||||
|
|
|
@ -5,7 +5,7 @@ copy(src, dst) - Full copy of 'src' to 'dst'
|
|||
"""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the macostools module is removed.")
|
||||
warnpy3k("In 3.x, the macostools module is removed.", stacklevel=2)
|
||||
|
||||
from Carbon import Res
|
||||
from Carbon import File, Files
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""macresource - Locate and open the resources needed for a script."""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the macresource module is removed.")
|
||||
warnpy3k("In 3.x, the macresource module is removed.", stacklevel=2)
|
||||
|
||||
from Carbon import Res
|
||||
import os
|
||||
|
|
|
@ -14,7 +14,7 @@ intention is that the end user will use this through a GUI.
|
|||
"""
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the pimp module is removed.")
|
||||
warnpy3k("In 3.x, the pimp module is removed.", stacklevel=2)
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
|
|
@ -15,7 +15,7 @@ with a decent input/output window.
|
|||
#
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the terminalcommand module is removed.")
|
||||
warnpy3k("In 3.x, the terminalcommand module is removed.", stacklevel=2)
|
||||
|
||||
import time
|
||||
import os
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("In 3.x, the videoreader module is removed.")
|
||||
warnpy3k("In 3.x, the videoreader module is removed.", stacklevel=2)
|
||||
|
||||
|
||||
import sys
|
||||
|
|
|
@ -74,7 +74,8 @@ There are also some utility functions here.
|
|||
import time
|
||||
|
||||
from warnings import warnpy3k
|
||||
warnpy3k("in 3.x, rfc822 has been removed in favor of the email package")
|
||||
warnpy3k("in 3.x, rfc822 has been removed in favor of the email package",
|
||||
stacklevel=2)
|
||||
|
||||
__all__ = ["Message","AddressList","parsedate","parsedate_tz","mktime_tz"]
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ from test.test_support import (catch_warning, CleanImport,
|
|||
TestSkipped, run_unittest)
|
||||
import warnings
|
||||
|
||||
from contextlib import nested
|
||||
|
||||
if not sys.py3kwarning:
|
||||
raise TestSkipped('%s must be run with the -3 flag' % __name__)
|
||||
|
||||
|
@ -193,7 +195,7 @@ class TestStdlibRemovals(unittest.TestCase):
|
|||
'Explorer', 'Finder', 'Netscape',
|
||||
'StdSuites', 'SystemEvents', 'Terminal',
|
||||
'cfmfile', 'bundlebuilder', 'buildtools',
|
||||
'ColorPicker'),
|
||||
'ColorPicker', 'Audio_mac'),
|
||||
'sunos5' : ('sunaudiodev', 'SUNAUDIODEV'),
|
||||
}
|
||||
optional_modules = ('bsddb185', 'Canvas', 'dl', 'linuxaudiodev', 'imageop',
|
||||
|
@ -202,23 +204,22 @@ class TestStdlibRemovals(unittest.TestCase):
|
|||
def check_removal(self, module_name, optional=False):
|
||||
"""Make sure the specified module, when imported, raises a
|
||||
DeprecationWarning and specifies itself in the message."""
|
||||
with CleanImport(module_name):
|
||||
with catch_warning(record=False):
|
||||
warnings.filterwarnings("error", ".+ removed",
|
||||
DeprecationWarning)
|
||||
try:
|
||||
__import__(module_name, level=0)
|
||||
except DeprecationWarning as exc:
|
||||
self.assert_(module_name in exc.args[0],
|
||||
"%s warning didn't contain module name"
|
||||
% module_name)
|
||||
except ImportError:
|
||||
if not optional:
|
||||
self.fail("Non-optional module {0} raised an "
|
||||
"ImportError.".format(module_name))
|
||||
else:
|
||||
self.fail("DeprecationWarning not raised for {0}"
|
||||
.format(module_name))
|
||||
with nested(CleanImport(module_name), catch_warning(record=False)):
|
||||
warnings.filterwarnings("error", ".+ removed",
|
||||
DeprecationWarning, __name__)
|
||||
try:
|
||||
__import__(module_name, level=0)
|
||||
except DeprecationWarning as exc:
|
||||
self.assert_(module_name in exc.args[0],
|
||||
"%s warning didn't contain module name"
|
||||
% module_name)
|
||||
except ImportError:
|
||||
if not optional:
|
||||
self.fail("Non-optional module {0} raised an "
|
||||
"ImportError.".format(module_name))
|
||||
else:
|
||||
self.fail("DeprecationWarning not raised for {0}"
|
||||
.format(module_name))
|
||||
|
||||
def test_platform_independent_removals(self):
|
||||
# Make sure that the modules that are available on all platforms raise
|
||||
|
|
Loading…
Reference in New Issue