bpo-31658: Make xml.sax.parse accepting Path objects by BoboTiG · Pull Request #8564 · python/cpython

Expand Up @@ -21,7 +21,7 @@ import shutil from urllib.error import URLError from test import support from test.support import findfile, run_unittest, TESTFN from test.support import findfile, run_unittest, FakePath, TESTFN
TEST_XMLFILE = findfile("test.xml", subdir="xmltestdata") TEST_XMLFILE_OUT = findfile("test.xml.out", subdir="xmltestdata") Expand Down Expand Up @@ -182,6 +182,10 @@ def test_parse_bytes(self): with self.assertRaises(SAXException): self.check_parse(f)
def test_parse_path_object(self): make_xml_file(self.data, 'utf-8', None) self.check_parse(FakePath(TESTFN))
def test_parse_InputSource(self): # accept data without declared but with explicitly specified encoding make_xml_file(self.data, 'iso-8859-1', None) Expand Down Expand Up @@ -397,6 +401,13 @@ def test_string(self): self.checkContent(prep.getByteStream(), b"This was read from a file.")
def test_path_objects(self): # If the source is a Path object, use it as a system ID and open it. prep = prepare_input_source(FakePath(self.file)) self.assertIsNone(prep.getCharacterStream()) self.checkContent(prep.getByteStream(), b"This was read from a file.")
def test_binary_file(self): # If the source is a binary file-like object, use it as a byte # stream. Expand Down