Skip to content

Commit d061837

Browse files
committed
Update test_configparser.py from CPython v3.12.0
1 parent defc3ac commit d061837

File tree

1 file changed

+7
-39
lines changed

1 file changed

+7
-39
lines changed

Lib/test/test_configparser.py

+7-39
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def basic_test(self, cf):
114114

115115
# The use of spaces in the section names serves as a
116116
# regression test for SourceForge bug #583248:
117-
# http://www.python.org/sf/583248
117+
# https://bugs.python.org/issue583248
118118

119119
# API access
120120
eq(cf.get('Foo Bar', 'foo'), 'bar1')
@@ -934,7 +934,7 @@ def test_items(self):
934934
('name', 'value')])
935935

936936
def test_safe_interpolation(self):
937-
# See http://www.python.org/sf/511737
937+
# See https://bugs.python.org/issue511737
938938
cf = self.fromstring("[section]\n"
939939
"option1{eq}xxx\n"
940940
"option2{eq}%(option1)s/xxx\n"
@@ -1614,23 +1614,12 @@ def test_interpolation_depth_error(self):
16141614
self.assertEqual(error.section, 'section')
16151615

16161616
def test_parsing_error(self):
1617-
with self.assertRaises(ValueError) as cm:
1617+
with self.assertRaises(TypeError) as cm:
16181618
configparser.ParsingError()
1619-
self.assertEqual(str(cm.exception), "Required argument `source' not "
1620-
"given.")
1621-
with self.assertRaises(ValueError) as cm:
1622-
configparser.ParsingError(source='source', filename='filename')
1623-
self.assertEqual(str(cm.exception), "Cannot specify both `filename' "
1624-
"and `source'. Use `source'.")
1625-
error = configparser.ParsingError(filename='source')
1619+
error = configparser.ParsingError(source='source')
1620+
self.assertEqual(error.source, 'source')
1621+
error = configparser.ParsingError('source')
16261622
self.assertEqual(error.source, 'source')
1627-
with warnings.catch_warnings(record=True) as w:
1628-
warnings.simplefilter("always", DeprecationWarning)
1629-
self.assertEqual(error.filename, 'source')
1630-
error.filename = 'filename'
1631-
self.assertEqual(error.source, 'filename')
1632-
for warning in w:
1633-
self.assertTrue(warning.category is DeprecationWarning)
16341623

16351624
def test_interpolation_validation(self):
16361625
parser = configparser.ConfigParser()
@@ -1649,27 +1638,6 @@ def test_interpolation_validation(self):
16491638
self.assertEqual(str(cm.exception), "bad interpolation variable "
16501639
"reference '%(()'")
16511640

1652-
def test_readfp_deprecation(self):
1653-
sio = io.StringIO("""
1654-
[section]
1655-
option = value
1656-
""")
1657-
parser = configparser.ConfigParser()
1658-
with warnings.catch_warnings(record=True) as w:
1659-
warnings.simplefilter("always", DeprecationWarning)
1660-
parser.readfp(sio, filename='StringIO')
1661-
for warning in w:
1662-
self.assertTrue(warning.category is DeprecationWarning)
1663-
self.assertEqual(len(parser), 2)
1664-
self.assertEqual(parser['section']['option'], 'value')
1665-
1666-
def test_safeconfigparser_deprecation(self):
1667-
with warnings.catch_warnings(record=True) as w:
1668-
warnings.simplefilter("always", DeprecationWarning)
1669-
parser = configparser.SafeConfigParser()
1670-
for warning in w:
1671-
self.assertTrue(warning.category is DeprecationWarning)
1672-
16731641
def test_legacyinterpolation_deprecation(self):
16741642
with warnings.catch_warnings(record=True) as w:
16751643
warnings.simplefilter("always", DeprecationWarning)
@@ -1843,7 +1811,7 @@ def test_parsingerror(self):
18431811
self.assertEqual(e1.source, e2.source)
18441812
self.assertEqual(e1.errors, e2.errors)
18451813
self.assertEqual(repr(e1), repr(e2))
1846-
e1 = configparser.ParsingError(filename='filename')
1814+
e1 = configparser.ParsingError('filename')
18471815
e1.append(1, 'line1')
18481816
e1.append(2, 'line2')
18491817
e1.append(3, 'line3')

0 commit comments

Comments
 (0)