mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Update test_configparser.py from CPython v3.12.0
This commit is contained in:
1 parent
defc3ac7f1
commit
d061837467
1 file changed
+7
-39
Vendored
+7
-39
@@ -114,7 +114,7 @@ class BasicTestCase(CfgParserTestCaseClass):
|
||||
|
||||
# The use of spaces in the section names serves as a
|
||||
# regression test for SourceForge bug #583248:
|
||||
# http://www.python.org/sf/583248
|
||||
# https://bugs.python.org/issue583248
|
||||
|
||||
# API access
|
||||
eq(cf.get('Foo Bar', 'foo'), 'bar1')
|
||||
@@ -934,7 +934,7 @@ class ConfigParserTestCase(BasicTestCase, unittest.TestCase):
|
||||
('name', 'value')])
|
||||
|
||||
def test_safe_interpolation(self):
|
||||
# See http://www.python.org/sf/511737
|
||||
# See https://bugs.python.org/issue511737
|
||||
cf = self.fromstring("[section]\n"
|
||||
"option1{eq}xxx\n"
|
||||
"option2{eq}%(option1)s/xxx\n"
|
||||
@@ -1614,23 +1614,12 @@ class CoverageOneHundredTestCase(unittest.TestCase):
|
||||
self.assertEqual(error.section, 'section')
|
||||
|
||||
def test_parsing_error(self):
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
with self.assertRaises(TypeError) as cm:
|
||||
configparser.ParsingError()
|
||||
self.assertEqual(str(cm.exception), "Required argument `source' not "
|
||||
"given.")
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
configparser.ParsingError(source='source', filename='filename')
|
||||
self.assertEqual(str(cm.exception), "Cannot specify both `filename' "
|
||||
"and `source'. Use `source'.")
|
||||
error = configparser.ParsingError(filename='source')
|
||||
error = configparser.ParsingError(source='source')
|
||||
self.assertEqual(error.source, 'source')
|
||||
error = configparser.ParsingError('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()
|
||||
@@ -1649,27 +1638,6 @@ 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_legacyinterpolation_deprecation(self):
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
warnings.simplefilter("always", DeprecationWarning)
|
||||
@@ -1843,7 +1811,7 @@ class ExceptionPicklingTestCase(unittest.TestCase):
|
||||
self.assertEqual(e1.source, e2.source)
|
||||
self.assertEqual(e1.errors, e2.errors)
|
||||
self.assertEqual(repr(e1), repr(e2))
|
||||
e1 = configparser.ParsingError(filename='filename')
|
||||
e1 = configparser.ParsingError('filename')
|
||||
e1.append(1, 'line1')
|
||||
e1.append(2, 'line2')
|
||||
e1.append(3, 'line3')
|
||||
|
||||
Reference in new issue
Block a user