Issue 19713: Add PEP 451-related deprecations.

This commit is contained in:
Eric Snow 2014-01-06 20:49:04 -07:00
parent 02b9f9d6bb
commit 1500d49c22
15 changed files with 4348 additions and 4047 deletions

View file

@ -12,6 +12,7 @@
# 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 @@ def load(self, loader):
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 @@ def run_test(self, line_ending):
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 @@ def test_lf(self):
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 @@ def load(self, loader):
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)