Commit a6864e0d authored by Benjamin Peterson's avatar Benjamin Peterson

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