summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cfgparser.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-09-22 22:35:38 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-09-22 22:35:38 (GMT)
commit42d544505fff126ba131ca20c455c3245a5687a1 (patch)
tree614162a7e49828051a956bb6a74eb246fccdac18 /Lib/test/test_cfgparser.py
parent31c604d3a7ed0872b0a861ce8480245ff31db37c (diff)
downloadcpython-42d544505fff126ba131ca20c455c3245a5687a1.zip
cpython-42d544505fff126ba131ca20c455c3245a5687a1.tar.gz
cpython-42d544505fff126ba131ca20c455c3245a5687a1.tar.bz2
Fix typo and add test case.
Diffstat (limited to 'Lib/test/test_cfgparser.py')
-rw-r--r--Lib/test/test_cfgparser.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py
index 3079cfb..ad9b62a 100644
--- a/Lib/test/test_cfgparser.py
+++ b/Lib/test/test_cfgparser.py
@@ -328,9 +328,24 @@ boolean {0[0]} NO
e = self.parse_error(cf, configparser.ParsingError,
"[Foo]\n wrong-indent\n")
self.assertEqual(e.args, ('<???>',))
+ # read_file on a real file
+ tricky = support.findfile("cfgparser.3")
+ if self.delimiters[0] == '=':
+ error = configparser.ParsingError
+ expected = (tricky,)
+ else:
+ error = configparser.MissingSectionHeaderError
+ expected = (tricky, 1,
+ ' # INI with as many tricky parts as possible\n')
+ with open(tricky) as f:
+ e = self.parse_error(cf, error, f)
+ self.assertEqual(e.args, expected)
def parse_error(self, cf, exc, src):
- sio = io.StringIO(src)
+ if hasattr(src, 'readline'):
+ sio = src
+ else:
+ sio = io.StringIO(src)
with self.assertRaises(exc) as cm:
cf.read_file(sio)
return cm.exception