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.
diff --git a/Lib/mimetools.py b/Lib/mimetools.py
index 5dd5396..02963b5 100644
--- a/Lib/mimetools.py
+++ b/Lib/mimetools.py
@@ -6,7 +6,8 @@
 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"]
diff --git a/Lib/plat-mac/Audio_mac.py b/Lib/plat-mac/Audio_mac.py
index 3c8a74c..ddf2a1c 100644
--- a/Lib/plat-mac/Audio_mac.py
+++ b/Lib/plat-mac/Audio_mac.py
@@ -2,7 +2,7 @@
 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:
 
diff --git a/Lib/plat-mac/Carbon/__init__.py b/Lib/plat-mac/Carbon/__init__.py
index 664dcec..6739bbd 100644
--- a/Lib/plat-mac/Carbon/__init__.py
+++ b/Lib/plat-mac/Carbon/__init__.py
@@ -4,4 +4,4 @@
 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)
diff --git a/Lib/plat-mac/EasyDialogs.py b/Lib/plat-mac/EasyDialogs.py
index f3d7e78..4c64839 100644
--- a/Lib/plat-mac/EasyDialogs.py
+++ b/Lib/plat-mac/EasyDialogs.py
@@ -19,7 +19,7 @@
 """
 
 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
diff --git a/Lib/plat-mac/FrameWork.py b/Lib/plat-mac/FrameWork.py
index 75588a6..69401dd 100644
--- a/Lib/plat-mac/FrameWork.py
+++ b/Lib/plat-mac/FrameWork.py
@@ -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
diff --git a/Lib/plat-mac/MiniAEFrame.py b/Lib/plat-mac/MiniAEFrame.py
index 7d2d5f5..8d758c3 100644
--- a/Lib/plat-mac/MiniAEFrame.py
+++ b/Lib/plat-mac/MiniAEFrame.py
@@ -7,7 +7,7 @@
 """
 
 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
diff --git a/Lib/plat-mac/PixMapWrapper.py b/Lib/plat-mac/PixMapWrapper.py
index 45cb5f9..5ce3043 100644
--- a/Lib/plat-mac/PixMapWrapper.py
+++ b/Lib/plat-mac/PixMapWrapper.py
@@ -7,7 +7,7 @@
 
 
 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
diff --git a/Lib/plat-mac/aepack.py b/Lib/plat-mac/aepack.py
index b849c9d..3b31b04 100644
--- a/Lib/plat-mac/aepack.py
+++ b/Lib/plat-mac/aepack.py
@@ -13,7 +13,7 @@
 #
 
 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
diff --git a/Lib/plat-mac/aetools.py b/Lib/plat-mac/aetools.py
index 9618b81..bf27663 100644
--- a/Lib/plat-mac/aetools.py
+++ b/Lib/plat-mac/aetools.py
@@ -22,7 +22,7 @@
 
 
 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
diff --git a/Lib/plat-mac/aetypes.py b/Lib/plat-mac/aetypes.py
index c6c9026..5e3555e 100644
--- a/Lib/plat-mac/aetypes.py
+++ b/Lib/plat-mac/aetypes.py
@@ -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
diff --git a/Lib/plat-mac/applesingle.py b/Lib/plat-mac/applesingle.py
index 0e2cf91..f6c605f 100644
--- a/Lib/plat-mac/applesingle.py
+++ b/Lib/plat-mac/applesingle.py
@@ -2,7 +2,7 @@
 """
 
 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
diff --git a/Lib/plat-mac/appletrawmain.py b/Lib/plat-mac/appletrawmain.py
index 7fc51d8..c863486 100644
--- a/Lib/plat-mac/appletrawmain.py
+++ b/Lib/plat-mac/appletrawmain.py
@@ -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
diff --git a/Lib/plat-mac/appletrunner.py b/Lib/plat-mac/appletrunner.py
index b47fa42..a2373aa 100755
--- a/Lib/plat-mac/appletrunner.py
+++ b/Lib/plat-mac/appletrunner.py
@@ -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
diff --git a/Lib/plat-mac/argvemulator.py b/Lib/plat-mac/argvemulator.py
index 1bc5da6..3dfc9f8 100644
--- a/Lib/plat-mac/argvemulator.py
+++ b/Lib/plat-mac/argvemulator.py
@@ -3,7 +3,7 @@
 """
 
 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
diff --git a/Lib/plat-mac/bgenlocations.py b/Lib/plat-mac/bgenlocations.py
index 7643e4b..38f4159 100644
--- a/Lib/plat-mac/bgenlocations.py
+++ b/Lib/plat-mac/bgenlocations.py
@@ -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"
 #
diff --git a/Lib/plat-mac/buildtools.py b/Lib/plat-mac/buildtools.py
index 0081e65..3480226 100644
--- a/Lib/plat-mac/buildtools.py
+++ b/Lib/plat-mac/buildtools.py
@@ -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
diff --git a/Lib/plat-mac/bundlebuilder.py b/Lib/plat-mac/bundlebuilder.py
index 46c17df..f0c7fc2 100755
--- a/Lib/plat-mac/bundlebuilder.py
+++ b/Lib/plat-mac/bundlebuilder.py
@@ -29,7 +29,7 @@
 
 
 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
diff --git a/Lib/plat-mac/cfmfile.py b/Lib/plat-mac/cfmfile.py
index 309af87..ddbd468 100644
--- a/Lib/plat-mac/cfmfile.py
+++ b/Lib/plat-mac/cfmfile.py
@@ -6,8 +6,8 @@
 __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
diff --git a/Lib/plat-mac/findertools.py b/Lib/plat-mac/findertools.py
index 038ee09..56e7980 100644
--- a/Lib/plat-mac/findertools.py
+++ b/Lib/plat-mac/findertools.py
@@ -16,7 +16,7 @@
 """
 
 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
diff --git a/Lib/plat-mac/gensuitemodule.py b/Lib/plat-mac/gensuitemodule.py
index c92d1eb..28ebea6 100644
--- a/Lib/plat-mac/gensuitemodule.py
+++ b/Lib/plat-mac/gensuitemodule.py
@@ -7,7 +7,7 @@
 """
 
 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
diff --git a/Lib/plat-mac/ic.py b/Lib/plat-mac/ic.py
index beb8226..8337f2d 100644
--- a/Lib/plat-mac/ic.py
+++ b/Lib/plat-mac/ic.py
@@ -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
diff --git a/Lib/plat-mac/icopen.py b/Lib/plat-mac/icopen.py
index 7b8e8f3..941dbb6 100644
--- a/Lib/plat-mac/icopen.py
+++ b/Lib/plat-mac/icopen.py
@@ -38,7 +38,7 @@
 """
 
 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__
 
diff --git a/Lib/plat-mac/lib-scriptpackages/CodeWarrior/__init__.py b/Lib/plat-mac/lib-scriptpackages/CodeWarrior/__init__.py
index 89583d3..38e3350 100644
--- a/Lib/plat-mac/lib-scriptpackages/CodeWarrior/__init__.py
+++ b/Lib/plat-mac/lib-scriptpackages/CodeWarrior/__init__.py
@@ -3,7 +3,7 @@
 """
 
 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
diff --git a/Lib/plat-mac/lib-scriptpackages/Explorer/__init__.py b/Lib/plat-mac/lib-scriptpackages/Explorer/__init__.py
index 8e9438a..967bc0e 100644
--- a/Lib/plat-mac/lib-scriptpackages/Explorer/__init__.py
+++ b/Lib/plat-mac/lib-scriptpackages/Explorer/__init__.py
@@ -3,7 +3,7 @@
 """
 
 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
diff --git a/Lib/plat-mac/lib-scriptpackages/Finder/__init__.py b/Lib/plat-mac/lib-scriptpackages/Finder/__init__.py
index 8c9b026..84d178d 100644
--- a/Lib/plat-mac/lib-scriptpackages/Finder/__init__.py
+++ b/Lib/plat-mac/lib-scriptpackages/Finder/__init__.py
@@ -3,7 +3,7 @@
 """
 
 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
diff --git a/Lib/plat-mac/lib-scriptpackages/Netscape/__init__.py b/Lib/plat-mac/lib-scriptpackages/Netscape/__init__.py
index 7f0dfe2..802f18a 100644
--- a/Lib/plat-mac/lib-scriptpackages/Netscape/__init__.py
+++ b/Lib/plat-mac/lib-scriptpackages/Netscape/__init__.py
@@ -3,7 +3,7 @@
 """
 
 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
diff --git a/Lib/plat-mac/lib-scriptpackages/StdSuites/__init__.py b/Lib/plat-mac/lib-scriptpackages/StdSuites/__init__.py
index 15e03ec..b96055d 100644
--- a/Lib/plat-mac/lib-scriptpackages/StdSuites/__init__.py
+++ b/Lib/plat-mac/lib-scriptpackages/StdSuites/__init__.py
@@ -4,7 +4,7 @@
 """
 
 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
diff --git a/Lib/plat-mac/lib-scriptpackages/SystemEvents/__init__.py b/Lib/plat-mac/lib-scriptpackages/SystemEvents/__init__.py
index 8029224..80ce28e 100644
--- a/Lib/plat-mac/lib-scriptpackages/SystemEvents/__init__.py
+++ b/Lib/plat-mac/lib-scriptpackages/SystemEvents/__init__.py
@@ -3,7 +3,7 @@
 """
 
 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
diff --git a/Lib/plat-mac/lib-scriptpackages/Terminal/__init__.py b/Lib/plat-mac/lib-scriptpackages/Terminal/__init__.py
index 5aa8a1e..00330b9 100644
--- a/Lib/plat-mac/lib-scriptpackages/Terminal/__init__.py
+++ b/Lib/plat-mac/lib-scriptpackages/Terminal/__init__.py
@@ -3,7 +3,7 @@
 """
 
 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
diff --git a/Lib/plat-mac/lib-scriptpackages/_builtinSuites/__init__.py b/Lib/plat-mac/lib-scriptpackages/_builtinSuites/__init__.py
index 5061204..b675b98 100644
--- a/Lib/plat-mac/lib-scriptpackages/_builtinSuites/__init__.py
+++ b/Lib/plat-mac/lib-scriptpackages/_builtinSuites/__init__.py
@@ -6,7 +6,7 @@
 """
 
 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
diff --git a/Lib/plat-mac/macerrors.py b/Lib/plat-mac/macerrors.py
index 9629a0f..de1c1e2 100644
--- a/Lib/plat-mac/macerrors.py
+++ b/Lib/plat-mac/macerrors.py
@@ -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.
diff --git a/Lib/plat-mac/macostools.py b/Lib/plat-mac/macostools.py
index 643ba67..d7724fa 100644
--- a/Lib/plat-mac/macostools.py
+++ b/Lib/plat-mac/macostools.py
@@ -5,7 +5,7 @@
 """
 
 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
diff --git a/Lib/plat-mac/macresource.py b/Lib/plat-mac/macresource.py
index 0a66d76..f02453b 100644
--- a/Lib/plat-mac/macresource.py
+++ b/Lib/plat-mac/macresource.py
@@ -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
diff --git a/Lib/plat-mac/pimp.py b/Lib/plat-mac/pimp.py
index b3138bd..5fc16f0 100644
--- a/Lib/plat-mac/pimp.py
+++ b/Lib/plat-mac/pimp.py
@@ -14,7 +14,7 @@
 """
 
 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
diff --git a/Lib/plat-mac/terminalcommand.py b/Lib/plat-mac/terminalcommand.py
index 238781a..ef8cb6c 100644
--- a/Lib/plat-mac/terminalcommand.py
+++ b/Lib/plat-mac/terminalcommand.py
@@ -15,7 +15,7 @@
 #
 
 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
diff --git a/Lib/plat-mac/videoreader.py b/Lib/plat-mac/videoreader.py
index 43027d4..fbb37e1 100644
--- a/Lib/plat-mac/videoreader.py
+++ b/Lib/plat-mac/videoreader.py
@@ -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
diff --git a/Lib/rfc822.py b/Lib/rfc822.py
index 4382a51..64cd702 100644
--- a/Lib/rfc822.py
+++ b/Lib/rfc822.py
@@ -74,7 +74,8 @@
 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"]
 
diff --git a/Lib/test/test_py3kwarn.py b/Lib/test/test_py3kwarn.py
index 0d01572..0ddc979 100644
--- a/Lib/test/test_py3kwarn.py
+++ b/Lib/test/test_py3kwarn.py
@@ -4,6 +4,8 @@
                                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 @@
                                       '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 @@
     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