diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2014-01-07 03:49:04 (GMT) |
---|---|---|
committer | Eric Snow <ericsnowcurrently@gmail.com> | 2014-01-07 03:49:04 (GMT) |
commit | 1500d49c22e1a38d186f2dddfa6ba2c5a6cd7d5e (patch) | |
tree | ee32b3fd82c294c8bf257949a22481121d8ef246 /Lib/test/test_importlib/source/test_source_encoding.py | |
parent | 02b9f9d6bb596d437ac10d71afac8a4781d18d86 (diff) | |
download | cpython-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_source_encoding.py')
-rw-r--r-- | Lib/test/test_importlib/source/test_source_encoding.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/Lib/test/test_importlib/source/test_source_encoding.py b/Lib/test/test_importlib/source/test_source_encoding.py index aaf0041..c62dfa1 100644 --- a/Lib/test/test_importlib/source/test_source_encoding.py +++ b/Lib/test/test_importlib/source/test_source_encoding.py @@ -12,6 +12,7 @@ import types # imported for the parser to use. import unicodedata import unittest +import warnings CODING_RE = re.compile(r'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)', re.ASCII) @@ -102,7 +103,9 @@ Frozen_EncodingTestPEP451, Source_EncodingTestPEP451 = util.test_both( class EncodingTestPEP302(EncodingTest): def load(self, loader): - return loader.load_module(self.module_name) + with warnings.catch_warnings(): + warnings.simplefilter('ignore', DeprecationWarning) + return loader.load_module(self.module_name) Frozen_EncodingTestPEP302, Source_EncodingTestPEP302 = util.test_both( EncodingTestPEP302, machinery=machinery) @@ -121,8 +124,8 @@ class LineEndingTest: with open(mapping[module_name], 'wb') as file: file.write(source) loader = self.machinery.SourceFileLoader(module_name, - mapping[module_name]) - return loader.load_module(module_name) + mapping[module_name]) + return self.load(loader, module_name) # [cr] def test_cr(self): @@ -138,9 +141,9 @@ class LineEndingTest: class LineEndingTestPEP451(LineEndingTest): - def load(self, loader): - module = types.ModuleType(self.module_name) - module.__spec__ = importlib.util.spec_from_loader(self.module_name, loader) + def load(self, loader, module_name): + module = types.ModuleType(module_name) + module.__spec__ = importlib.util.spec_from_loader(module_name, loader) loader.exec_module(module) return module @@ -149,8 +152,10 @@ Frozen_LineEndingTestPEP451, Source_LineEndingTestPEP451 = util.test_both( class LineEndingTestPEP302(LineEndingTest): - def load(self, loader): - return loader.load_module(self.module_name) + def load(self, loader, module_name): + with warnings.catch_warnings(): + warnings.simplefilter('ignore', DeprecationWarning) + return loader.load_module(module_name) Frozen_LineEndingTestPEP302, Source_LineEndingTestPEP302 = util.test_both( LineEndingTestPEP302, machinery=machinery) |