aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_configparser.py
diff options
context:
space:
mode:
authorVincent Michel <vxgmichel@gmail.com>2017-11-02 13:47:04 +0100
committerBerker Peksag <berker.peksag@gmail.com>2017-11-02 15:47:04 +0300
commite314853d57450b2b9523157eebd405289a795a0e (patch)
treec410df1fbf11b9ec522e915819c58f5f53cbd27a /Lib/test/test_configparser.py
parenta64ce973a3ad90e4f4a93c402e946c132f647a63 (diff)
downloadcpython-e314853d57450b2b9523157eebd405289a795a0e.tar.gz
cpython-e314853d57450b2b9523157eebd405289a795a0e.zip
bpo-31307: Make ConfigParser.read() accept bytes objects (GH-3420)
Diffstat (limited to 'Lib/test/test_configparser.py')
-rw-r--r--Lib/test/test_configparser.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_configparser.py b/Lib/test/test_configparser.py
index d8969efc4db..4d07203b9da 100644
--- a/Lib/test/test_configparser.py
+++ b/Lib/test/test_configparser.py
@@ -740,6 +740,23 @@ boolean {0[0]} NO
parsed_files = cf.read([])
self.assertEqual(parsed_files, [])
+ def test_read_returns_file_list_with_bytestring_path(self):
+ if self.delimiters[0] != '=':
+ self.skipTest('incompatible format')
+ file1_bytestring = support.findfile("cfgparser.1").encode()
+ # check when passing an existing bytestring path
+ cf = self.newconfig()
+ parsed_files = cf.read(file1_bytestring)
+ self.assertEqual(parsed_files, [file1_bytestring])
+ # check when passing an non-existing bytestring path
+ cf = self.newconfig()
+ parsed_files = cf.read(b'nonexistent-file')
+ self.assertEqual(parsed_files, [])
+ # check when passing both an existing and non-existing bytestring path
+ cf = self.newconfig()
+ parsed_files = cf.read([file1_bytestring, b'nonexistent-file'])
+ self.assertEqual(parsed_files, [file1_bytestring])
+
# shared by subclasses
def get_interpolation_config(self):
return self.fromstring(