diff options
author | Vincent Michel <vxgmichel@gmail.com> | 2017-11-02 13:47:04 +0100 |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2017-11-02 15:47:04 +0300 |
commit | e314853d57450b2b9523157eebd405289a795a0e (patch) | |
tree | c410df1fbf11b9ec522e915819c58f5f53cbd27a /Lib/test/test_configparser.py | |
parent | a64ce973a3ad90e4f4a93c402e946c132f647a63 (diff) | |
download | cpython-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.py | 17 |
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( |