mirror of
https://github.com/python/cpython.git
synced 2025-10-25 10:44:55 +00:00
Issue 19713: Add PEP 451-related deprecations.
This commit is contained in:
parent
02b9f9d6bb
commit
1500d49c22
15 changed files with 4348 additions and 4047 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue