summaryrefslogtreecommitdiff
path: root/Lib/test/test_py3kwarn.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_py3kwarn.py')
-rw-r--r--Lib/test/test_py3kwarn.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/Lib/test/test_py3kwarn.py b/Lib/test/test_py3kwarn.py
index 85a772d612..9db4fd86c1 100644
--- a/Lib/test/test_py3kwarn.py
+++ b/Lib/test/test_py3kwarn.py
@@ -183,9 +183,10 @@ class TestStdlibRemovals(unittest.TestCase):
class TestStdlibRenames(unittest.TestCase):
- renames = {'copy_reg': 'copyreg', 'Queue': 'queue'}
+ all_platforms = {'copy_reg': 'copyreg', 'Queue': 'queue'}
+ inclusive_platforms = {'mac': {'PixMapWrapper': 'pixmapwrapper'}}
- def check_rename(self, module_name, new_module_name):
+ def check_rename(self, module_name, new_module_name, optional=False):
"""Make sure that:
- A DeprecationWarning is raised when importing using the
old 2.x module name.
@@ -201,23 +202,32 @@ class TestStdlibRenames(unittest.TestCase):
except DeprecationWarning as exc:
self.assert_(module_name in exc.args[0])
self.assert_(new_module_name in exc.args[0])
+ except ImportError:
+ if not optional:
+ raise
else:
self.fail("DeprecationWarning not raised for %s" %
module_name)
with CleanImport(new_module_name):
try:
__import__(new_module_name, level=0)
- except ImportError:
- self.fail("cannot import %s with its 3.x name, %s" %
- module_name, new_module_name)
except DeprecationWarning:
self.fail("unexpected DeprecationWarning raised for %s" %
module_name)
+ except ImportError:
+ if not optional:
+ self.fail("cannot import %s with its 3.x name, %s" %
+ module_name, new_module_name)
- def test_module_renames(self):
- for module_name, new_module_name in self.renames.items():
+ def test_platform_independent_renames(self):
+ for module_name, new_module_name in self.all_platforms.items():
self.check_rename(module_name, new_module_name)
+ def test_platform_specific_renames(self):
+ renames = self.inclusive_platforms.get(sys.platform, {})
+ for module_name, new_module_name in renames.items():
+ self.check_removal(module_name, new_module_name, optional=True)
+
def test_main():
run_unittest(TestPy3KWarnings,