mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
bpo-45173: Keep configparser deprecations until Python 3.12 (GH-30952)
* Revert "bpo-45173 Remove configparser deprecations"
This reverts commit df2284bc41
.
* bpo-45173: Note these configparser deprecations will be removed in 3.12
This commit is contained in:
parent
38e0b9efdf
commit
e8659b47de
5 changed files with 105 additions and 11 deletions
|
@ -1612,6 +1612,13 @@ class CoverageOneHundredTestCase(unittest.TestCase):
|
|||
"and `source'. Use `source'.")
|
||||
error = configparser.ParsingError(filename='source')
|
||||
self.assertEqual(error.source, 'source')
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
warnings.simplefilter("always", DeprecationWarning)
|
||||
self.assertEqual(error.filename, 'source')
|
||||
error.filename = 'filename'
|
||||
self.assertEqual(error.source, 'filename')
|
||||
for warning in w:
|
||||
self.assertTrue(warning.category is DeprecationWarning)
|
||||
|
||||
def test_interpolation_validation(self):
|
||||
parser = configparser.ConfigParser()
|
||||
|
@ -1630,6 +1637,27 @@ class CoverageOneHundredTestCase(unittest.TestCase):
|
|||
self.assertEqual(str(cm.exception), "bad interpolation variable "
|
||||
"reference '%(()'")
|
||||
|
||||
def test_readfp_deprecation(self):
|
||||
sio = io.StringIO("""
|
||||
[section]
|
||||
option = value
|
||||
""")
|
||||
parser = configparser.ConfigParser()
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
warnings.simplefilter("always", DeprecationWarning)
|
||||
parser.readfp(sio, filename='StringIO')
|
||||
for warning in w:
|
||||
self.assertTrue(warning.category is DeprecationWarning)
|
||||
self.assertEqual(len(parser), 2)
|
||||
self.assertEqual(parser['section']['option'], 'value')
|
||||
|
||||
def test_safeconfigparser_deprecation(self):
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
warnings.simplefilter("always", DeprecationWarning)
|
||||
parser = configparser.SafeConfigParser()
|
||||
for warning in w:
|
||||
self.assertTrue(warning.category is DeprecationWarning)
|
||||
|
||||
def test_sectionproxy_repr(self):
|
||||
parser = configparser.ConfigParser()
|
||||
parser.read_string("""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue