()
| 305 | |
| 306 | |
| 307 | def test_clip_path_ids_reuse(): |
| 308 | fig, circle = Figure(), Circle((0, 0), radius=10) |
| 309 | for i in range(5): |
| 310 | ax = fig.add_subplot() |
| 311 | aimg = ax.imshow([[i]]) |
| 312 | aimg.set_clip_path(circle) |
| 313 | |
| 314 | inner_circle = Circle((0, 0), radius=1) |
| 315 | ax = fig.add_subplot() |
| 316 | aimg = ax.imshow([[0]]) |
| 317 | aimg.set_clip_path(inner_circle) |
| 318 | |
| 319 | with BytesIO() as fd: |
| 320 | fig.savefig(fd, format='svg') |
| 321 | buf = fd.getvalue() |
| 322 | |
| 323 | tree = xml.etree.ElementTree.fromstring(buf) |
| 324 | ns = 'http://www.w3.org/2000/svg' |
| 325 | |
| 326 | clip_path_ids = set() |
| 327 | for node in tree.findall(f'.//{{{ns}}}clipPath[@id]'): |
| 328 | node_id = node.attrib['id'] |
| 329 | assert node_id not in clip_path_ids # assert ID uniqueness |
| 330 | clip_path_ids.add(node_id) |
| 331 | assert len(clip_path_ids) == 2 # only two clipPaths despite reuse in multiple axes |
| 332 | |
| 333 | |
| 334 | def test_savefig_tight(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…