def test_parse_empty(mock_parse): def xmltree(source, parser=None, base_url=None): return etree.XML("""""").getroottree() mock_parse.side_effect = xmltree with pytest.raises(XMLSyntaxError): parse("fake.rng")
def test_parse(mock_parse): def xmltree(source, parser=None, base_url=None): return etree.XML( """<wrongelement xmlns="urn:x-test:wrong-ns"/>""").getroottree() mock_parse.side_effect = xmltree with pytest.raises(RelaxNGParseError): parse("fake.rng")
def test_transform_namespaces(xml, expected): result = parse(io.StringIO(xml)) assert isinstance(result, etree._ElementTree) for xpath, expected_value in expected: assert result.xpath(xpath) == expected_value