summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cfgparser.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2004-05-18 04:24:02 (GMT)
committerFred Drake <fdrake@acm.org>2004-05-18 04:24:02 (GMT)
commit82903148a8b4d7f27c5b3180331efd98600b21e1 (patch)
treeb3e2c38eb4933023f71475cfc7ab935587b2305b /Lib/test/test_cfgparser.py
parentb4c6091984d846e43667cd6be6a7e01e79dbc3d7 (diff)
downloadcpython-82903148a8b4d7f27c5b3180331efd98600b21e1.zip
cpython-82903148a8b4d7f27c5b3180331efd98600b21e1.tar.gz
cpython-82903148a8b4d7f27c5b3180331efd98600b21e1.tar.bz2
ConfigParser:
- read() method returns a list of files parsed successfully - add tests, documentation (closes SF patch #677651)
Diffstat (limited to 'Lib/test/test_cfgparser.py')
-rw-r--r--Lib/test/test_cfgparser.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py
index b40cedf..c799c7d 100644
--- a/Lib/test/test_cfgparser.py
+++ b/Lib/test/test_cfgparser.py
@@ -242,6 +242,27 @@ class TestCaseBase(unittest.TestCase):
self.assertRaises(TypeError, cf.set, "sect", "option2", 1.0)
self.assertRaises(TypeError, cf.set, "sect", "option2", object())
+ def test_read_returns_file_list(self):
+ file1 = test_support.findfile("cfgparser.1")
+ # check when we pass a mix of readable and non-readable files:
+ cf = self.newconfig()
+ parsed_files = cf.read([file1, "nonexistant-file"])
+ self.assertEqual(parsed_files, [file1])
+ self.assertEqual(cf.get("Foo Bar", "foo"), "newbar")
+ # check when we pass only a filename:
+ cf = self.newconfig()
+ parsed_files = cf.read(file1)
+ self.assertEqual(parsed_files, [file1])
+ self.assertEqual(cf.get("Foo Bar", "foo"), "newbar")
+ # check when we pass only missing files:
+ cf = self.newconfig()
+ parsed_files = cf.read(["nonexistant-file"])
+ self.assertEqual(parsed_files, [])
+ # check when we pass no files:
+ cf = self.newconfig()
+ parsed_files = cf.read([])
+ self.assertEqual(parsed_files, [])
+
# shared by subclasses
def get_interpolation_config(self):
return self.fromstring(