|
21 | 21 | import shutil |
22 | 22 | from urllib.error import URLError |
23 | 23 | from test import support |
24 | | -from test.support import findfile, run_unittest, TESTFN |
| 24 | +from test.support import findfile, run_unittest, FakePath, TESTFN |
25 | 25 |
|
26 | 26 | TEST_XMLFILE = findfile("test.xml", subdir="xmltestdata") |
27 | 27 | TEST_XMLFILE_OUT = findfile("test.xml.out", subdir="xmltestdata") |
@@ -182,6 +182,10 @@ def test_parse_bytes(self): |
182 | 182 | with self.assertRaises(SAXException): |
183 | 183 | self.check_parse(f) |
184 | 184 |
|
| 185 | + def test_parse_path_object(self): |
| 186 | + make_xml_file(self.data, 'utf-8', None) |
| 187 | + self.check_parse(FakePath(TESTFN)) |
| 188 | + |
185 | 189 | def test_parse_InputSource(self): |
186 | 190 | # accept data without declared but with explicitly specified encoding |
187 | 191 | make_xml_file(self.data, 'iso-8859-1', None) |
@@ -397,6 +401,13 @@ def test_string(self): |
397 | 401 | self.checkContent(prep.getByteStream(), |
398 | 402 | b"This was read from a file.") |
399 | 403 |
|
| 404 | + def test_path_objects(self): |
| 405 | + # If the source is a Path object, use it as a system ID and open it. |
| 406 | + prep = prepare_input_source(FakePath(self.file)) |
| 407 | + self.assertIsNone(prep.getCharacterStream()) |
| 408 | + self.checkContent(prep.getByteStream(), |
| 409 | + b"This was read from a file.") |
| 410 | + |
400 | 411 | def test_binary_file(self): |
401 | 412 | # If the source is a binary file-like object, use it as a byte |
402 | 413 | # stream. |
|
0 commit comments