@@ -355,15 +355,49 @@ def test_path_deepcopy():
355355 # Should not raise any error
356356 verts = [[0 , 0 ], [1 , 1 ]]
357357 codes = [Path .MOVETO , Path .LINETO ]
358- path1 = Path (verts )
359- path2 = Path (verts , codes )
358+ path1 = Path (verts , readonly = True )
359+ path2 = Path (verts , codes , readonly = True )
360360 path1_copy = path1 .deepcopy ()
361361 path2_copy = path2 .deepcopy ()
362362 assert path1 is not path1_copy
363363 assert path1 .vertices is not path1_copy .vertices
364+ assert_array_equal (path1 .vertices , path1_copy .vertices )
365+ assert path1 .readonly
366+ assert not path1_copy .readonly
364367 assert path2 is not path2_copy
365368 assert path2 .vertices is not path2_copy .vertices
369+ assert_array_equal (path2 .vertices , path2_copy .vertices )
366370 assert path2 .codes is not path2_copy .codes
371+ assert_array_equal (path2 .codes , path2_copy .codes )
372+ assert path2 .readonly
373+ assert not path2_copy .readonly
374+
375+
376+ def test_path_deepcopy_cycle ():
377+ class PathWithCycle (Path ):
378+ def __init__ (self , * args , ** kwargs ):
379+ super ().__init__ (* args , ** kwargs )
380+ self .x = self
381+
382+ p = PathWithCycle ([[0 , 0 ], [1 , 1 ]], readonly = True )
383+ p_copy = p .deepcopy ()
384+ assert p_copy is not p
385+ assert p .readonly
386+ assert not p_copy .readonly
387+ assert p_copy .x is p_copy
388+
389+ class PathWithCycle2 (Path ):
390+ def __init__ (self , * args , ** kwargs ):
391+ super ().__init__ (* args , ** kwargs )
392+ self .x = [self ] * 2
393+
394+ p2 = PathWithCycle2 ([[0 , 0 ], [1 , 1 ]], readonly = True )
395+ p2_copy = p2 .deepcopy ()
396+ assert p2_copy is not p2
397+ assert p2 .readonly
398+ assert not p2_copy .readonly
399+ assert p2_copy .x [0 ] is p2_copy
400+ assert p2_copy .x [1 ] is p2_copy
367401
368402
369403def test_path_shallowcopy ():
0 commit comments