def test_osm_xml() -> None:
    """Test working with .osm XML data."""
    # test loading a graph from a local .osm xml (and bz2 and gzip) file
    node_id = 53098262
    neighbor_ids = 53092170, 53060438, 53027353, 667744075

    # read the contents of the bzip2 file
    path_bz2 = "tests/input_data/West-Oakland.osm.bz2"
    with bz2.open(path_bz2, mode="rb") as f:
        file_contents = f.read()

    # write the contents to a .osm file
    path_osm_temp = path_bz2.strip(".bz2")
    with Path(path_osm_temp).open("wb") as f:
        f.write(file_contents)

    # write the contents to a gzip file
    path_gz_temp = path_osm_temp + ".gz"
    with gzip.open(path_gz_temp, mode="wb") as f:
        f.write(file_contents)

    # load and test graph_from_xml across the .osm, .bz2, and .gz files
    for filepath in (path_bz2, path_gz_temp, path_osm_temp):
        G = ox.graph_from_xml(filepath)
        assert node_id in G.nodes

        for neighbor_id in neighbor_ids:
            edge_key = (node_id, neighbor_id, 0)
            assert neighbor_id in G.nodes
            assert edge_key in G.edges
            assert G.edges[edge_key]["name"] in {"8th Street", "Willow Street"}

    # delete the temporary .osm and .gz files
    Path.unlink(Path(path_osm_temp))
    Path.unlink(Path(path_gz_temp))

    # test OSM xml saving
    G = ox.graph_from_point(location_point, dist=500, network_type="drive", simplify=False)
    fp = Path(ox.settings.data_folder) / "graph.osm"
    ox.io.save_graph_xml(G, filepath=fp, way_tag_aggs={"lanes": "sum"})

    # validate saved XML against XSD schema
    xsd_filepath = "./tests/input_data/osm_schema.xsd"
    parser = etree.XMLParser(schema=etree.XMLSchema(file=xsd_filepath))
    _ = etree.parse(fp, parser=parser)

    # test roundabout handling
    default_all_oneway = ox.settings.all_oneway
    ox.settings.all_oneway = True
    default_overpass_settings = ox.settings.overpass_settings
    ox.settings.overpass_settings += '[date:"2023-04-01T00:00:00Z"]'
    point = (39.0290346, -84.4696884)
    G = ox.graph_from_point(point, dist=500, dist_type="bbox", network_type="drive", simplify=False)
    ox.io.save_graph_xml(G)
    _ = etree.parse(fp, parser=parser)

    # raise error if trying to save a simplified graph
    with pytest.raises(ox._errors.GraphSimplificationError):
        ox.io.save_graph_xml(ox.simplification.simplify_graph(G))

    # save a projected/consolidated graph as OSM XML
    Gc = ox.simplification.consolidate_intersections(ox.projection.project_graph(G))
    nx.set_node_attributes(Gc, 0, name="uid")
    ox.io.save_graph_xml(Gc, fp)  # issues UserWarning
    Gc = ox.graph.graph_from_xml(fp)  # issues UserWarning
    _ = etree.parse(fp, parser=parser)

    # restore settings
    ox.settings.overpass_settings = default_overpass_settings
    ox.settings.all_oneway = default_all_oneway
Test working with .osm XML data.
tests/test_osmnx.py