summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_importlib/source/test_file_loader.py
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2014-01-07 03:49:04 (GMT)
committerEric Snow <ericsnowcurrently@gmail.com>2014-01-07 03:49:04 (GMT)
commit1500d49c22e1a38d186f2dddfa6ba2c5a6cd7d5e (patch)
treeee32b3fd82c294c8bf257949a22481121d8ef246 /Lib/test/test_importlib/source/test_file_loader.py
parent02b9f9d6bb596d437ac10d71afac8a4781d18d86 (diff)
downloadcpython-1500d49c22e1a38d186f2dddfa6ba2c5a6cd7d5e.zip
cpython-1500d49c22e1a38d186f2dddfa6ba2c5a6cd7d5e.tar.gz
cpython-1500d49c22e1a38d186f2dddfa6ba2c5a6cd7d5e.tar.bz2
Issue 19713: Add PEP 451-related deprecations.
Diffstat (limited to 'Lib/test/test_importlib/source/test_file_loader.py')
-rw-r--r--Lib/test/test_importlib/source/test_file_loader.py54
1 files changed, 41 insertions, 13 deletions
diff --git a/Lib/test/test_importlib/source/test_file_loader.py b/Lib/test/test_importlib/source/test_file_loader.py
index 16e4df2..25a3dae 100644
--- a/Lib/test/test_importlib/source/test_file_loader.py
+++ b/Lib/test/test_importlib/source/test_file_loader.py
@@ -16,6 +16,7 @@ import stat
import sys
import types
import unittest
+import warnings
from test.support import make_legacy_pyc, unload
@@ -39,7 +40,9 @@ class SimpleTest(abc.LoaderTests):
loader = Tester('blah', 'blah.py')
self.addCleanup(unload, 'blah')
- module = loader.load_module() # Should not raise an exception.
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ module = loader.load_module() # Should not raise an exception.
def test_get_filename_API(self):
# If fullname is not set then assume self.path is desired.
@@ -70,7 +73,9 @@ class SimpleTest(abc.LoaderTests):
def test_module(self):
with source_util.create_modules('_temp') as mapping:
loader = self.machinery.SourceFileLoader('_temp', mapping['_temp'])
- module = loader.load_module('_temp')
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ module = loader.load_module('_temp')
self.assertIn('_temp', sys.modules)
check = {'__name__': '_temp', '__file__': mapping['_temp'],
'__package__': ''}
@@ -81,7 +86,9 @@ class SimpleTest(abc.LoaderTests):
with source_util.create_modules('_pkg.__init__') as mapping:
loader = self.machinery.SourceFileLoader('_pkg',
mapping['_pkg.__init__'])
- module = loader.load_module('_pkg')
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ module = loader.load_module('_pkg')
self.assertIn('_pkg', sys.modules)
check = {'__name__': '_pkg', '__file__': mapping['_pkg.__init__'],
'__path__': [os.path.dirname(mapping['_pkg.__init__'])],
@@ -94,7 +101,9 @@ class SimpleTest(abc.LoaderTests):
with source_util.create_modules('_pkg.__init__', '_pkg.mod')as mapping:
loader = self.machinery.SourceFileLoader('_pkg.mod',
mapping['_pkg.mod'])
- module = loader.load_module('_pkg.mod')
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ module = loader.load_module('_pkg.mod')
self.assertIn('_pkg.mod', sys.modules)
check = {'__name__': '_pkg.mod', '__file__': mapping['_pkg.mod'],
'__package__': '_pkg'}
@@ -108,12 +117,16 @@ class SimpleTest(abc.LoaderTests):
def test_module_reuse(self):
with source_util.create_modules('_temp') as mapping:
loader = self.machinery.SourceFileLoader('_temp', mapping['_temp'])
- module = loader.load_module('_temp')
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ module = loader.load_module('_temp')
module_id = id(module)
module_dict_id = id(module.__dict__)
with open(mapping['_temp'], 'w') as file:
file.write("testing_var = 42\n")
- module = loader.load_module('_temp')
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ module = loader.load_module('_temp')
self.assertIn('testing_var', module.__dict__,
"'testing_var' not in "
"{0}".format(list(module.__dict__.keys())))
@@ -138,7 +151,9 @@ class SimpleTest(abc.LoaderTests):
for attr in attributes:
self.assertEqual(getattr(orig_module, attr), value)
with self.assertRaises(SyntaxError):
- loader.load_module(name)
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ loader.load_module(name)
for attr in attributes:
self.assertEqual(getattr(orig_module, attr), value)
@@ -149,7 +164,9 @@ class SimpleTest(abc.LoaderTests):
file.write('=')
loader = self.machinery.SourceFileLoader('_temp', mapping['_temp'])
with self.assertRaises(SyntaxError):
- loader.load_module('_temp')
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ loader.load_module('_temp')
self.assertNotIn('_temp', sys.modules)
def test_file_from_empty_string_dir(self):
@@ -161,7 +178,9 @@ class SimpleTest(abc.LoaderTests):
try:
with util.uncache('_temp'):
loader = self.machinery.SourceFileLoader('_temp', file_path)
- mod = loader.load_module('_temp')
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ mod = loader.load_module('_temp')
self.assertEqual(file_path, mod.__file__)
self.assertEqual(self.util.cache_from_source(file_path),
mod.__cached__)
@@ -196,7 +215,9 @@ class SimpleTest(abc.LoaderTests):
self.assertTrue(os.path.exists(compiled))
os.unlink(compiled)
# PEP 302
- mod = loader.load_module('_temp') # XXX
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ mod = loader.load_module('_temp') # XXX
# Sanity checks.
self.assertEqual(mod.__cached__, compiled)
self.assertEqual(mod.x, 5)
@@ -210,7 +231,9 @@ class SimpleTest(abc.LoaderTests):
with self.assertRaises(ImportError):
loader.exec_module(module)
with self.assertRaises(ImportError):
- loader.load_module('bad name')
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ loader.load_module('bad name')
Frozen_SimpleTest, Source_SimpleTest = util.test_both(
SimpleTest, importlib=importlib, machinery=machinery, abc=importlib_abc,
@@ -221,7 +244,10 @@ class BadBytecodeTest:
def import_(self, file, module_name):
loader = self.loader(module_name, file)
- module = loader.load_module(module_name)
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ # XXX Change to use exec_module().
+ module = loader.load_module(module_name)
self.assertIn(module_name, sys.modules)
def manipulate_bytecode(self, name, mapping, manipulator, *,
@@ -332,7 +358,9 @@ class BadBytecodeTestPEP302(BadBytecodeTest):
def import_(self, file, module_name):
loader = self.loader(module_name, file)
- module = loader.load_module(module_name)
+ with warnings.catch_warnings():
+ warnings.simplefilter('ignore', DeprecationWarning)
+ module = loader.load_module(module_name)
self.assertIn(module_name, sys.modules)