
    ]j'                         d dl Z d dlZd dlT  G d dej                  Z G d dej                  Z G d dej                  ZdS )	    N)*c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )
TestParserc                    t          d          }|                     |t          t          d          t          dd          t          dd          t	          dd                               |                     |j                   t          d          }|                     |t          t          d          t          dd          t          dd          t          dd          t          dd          t	          dd                               t          d          }t          d	          }|                     ||           t          d
          }t          d          }|                     ||           t          d          }|                     |t          t          d          t          dddd          t          dddd                               t          d          }|                     |t          t          d          t          dddd                               t          d          }|                     |t          t          d          t          dddd                               t          d          }|                     |t          t          d          t          dddd                               t          d          }|                     |t          t          d           t          d d!d"d#                               t          d$          }|                     |t          t          d%          t          d%d&d'd(                               t          d)          }|                     |t          t          d*          t          d*d+d,d-          t          d-d.d/d0                               t          d1          }|                     |t          t          d          t          dd2d3          t          d3d4d5                               t          d6          }|                     |t          t          d7          t          d7d8          t          d8d9d:d;d:d<          t	          d<d7                               t          d=          }|                     |t          t          d>          t          d>d?          t          d?d9d:d:d:d@          t	          d@d>                               t          dA          }|                     |t          t          d>          t          d>d?          t          d?d9d:d:d:d@          t          d@d>          t	          d>d>                               t          dB          }|                     |t          t          d&          t          d&dC          t          dCdDdEd:d;dF          t          dFdG          t          dGdHdEd:d;dI          t          dIdJ          t          dJdKdEd:d;d#          t          d#dL          t          dLdMdEd:d;dN          t          dNdO          
  
                   dPS )QzExamples from the SVG speczM 100 100 L 300 100 L 200 300 z      Y@      Y@     r@      Y@      i@     r@z-M 0 0 L 50 20 M 100 100 L 300 100 L 200 300 z                      I@      4@zM 100 100 L 200 200zM100 100L200 200zM 100 200 L 200 100 L -100 -200zM 100 200 L 200 100 -100 -200zPM100,200 C100,100 250,100 250,200
                              S400,300 400,200      Y@      i@     @o@      Y@     @o@      i@y     @o@     r@y      y@     r@y      y@      i@z!M100,200 C100,100 400,100 400,200y      y@      Y@z M100,500 C25,400 475,400 400,500y      Y@     @@y      9@      y@y     }@      y@y      y@     @@z!M100,800 C175,700 325,700 400,800y      Y@      @y     e@     @y     Pt@     @y      y@      @z!M600,200 C675,100 975,100 900,200y     @      i@y     @      Y@y     x@      Y@y      @      i@z!M600,500 C600,350 900,650 900,500y     @     @@y     @     u@y      @     P@y      @     @@zPM600,800 C625,700 725,700 750,800
                              S875,900 900,800y     @      @y     @     @y     @     @y     p@      @y     8@      @y     X@      @y      @      @z"M200,300 Q400,50 600,300 T1000,300y      y@      I@y     @     r@y      @     0@y     @@     r@z(M300,200 h-150 a150,150 0 1,0 150,-150 zy     r@      i@y     b@      i@     b@     b@r      y     r@      I@z(M275,175 v-150 a150,150 0 0,0 -150,150 zy     0q@     e@y     0q@      9@y     @_@     e@z2M275,175 v-150 a150,150 0 0,0 -150,150 L 275,175 za  M600,350 l 50,-25
                              a25,25 -30 0,1 50,-25 l 50,-25
                              a25,50 -30 0,1 50,-25 l 50,-25
                              a25,75 -30 0,1 50,-25 l 50,-25
                              a25,100 -30 0,1 50,-25 l 50,-25y     P@     Pt@      9@      9@iy     @     r@y     p@     0q@y      9@      I@y      @     @o@y     @      l@y      9@     R@y     @     e@y      9@      Y@y     @@     b@y     h@     @_@N)
PathassertEqualMoveLineClose
assertTrueclosedCubicBezierQuadraticBezierArcselfpath1path2s      L/home/agentuser/manim-venv/lib/python3.11/site-packages/test/test_parsing.pytest_svg_exampleszTestParser.test_svg_examples	   s   677T*%5%5%)*j%A%A%)*j%A%A%*:z%B%B!D !D 	E 	E 	E 	%%% DEEHH""8$$Z((Z((*j))!+ !+ 	, 	, 	, *++'((&&&677455&&& 2 3 3d:..)*j*jYY)*j*jYY[ [	\ 	\ 	\
 899d:..)*j*jYY[ [	\ 	\ 	\ 788d:..)*iZXXZ Z	[ 	[ 	[ 899d8nn)*j*jYY[ [	\ 	\ 	\ 899d:..)*j*jYY[ [	\ 	\ 	\ 899d:..)*j*jYY[ [	\ 	\ 	\  2 3 3d:..)*j*jYY)*j*jYY[ [	\ 	\ 	\
 9::d:..-j)ZPP-j*kRRT T	U 	U 	U
 ?@@d:..":z::!*j!Q9MM#Iz::< <	= 	= 	= ?@@d:..":y99!)ZAq*MM#J
;;= =	> 	> 	> IJJd:..":y99!)ZAq*MM":z::#J
;;	= =	> 	> 	>  A B B
 	d:..":z::!*hQ:NN":z::!*hQ:NN":z::!*hQ:NN":z::!*iaKPP";<<	> 	>
	? 
	? 
	? 
	? 
	?    c                    t           } |d          }|                     |t          t          d          t          dddd          t          ddd	d
                                |d          }|                     |t          t          d          t          dddd          t          dddd                               dS )z
        W3C_SVG_11_TestSuite Paths
        Test using multiple coord sets to build a polybeizer, and implicit values for initial S.
        zBM  100 100    C  100 20   200 20   200 100   S   300 180   300 100r   endy      Y@      4@y      i@      4@y      i@      Y@)startcontrol1control2r%   y      i@     f@y     r@     f@r   z8M  100 250    S  200 200   200 250     300 300   300 250y      Y@     @o@y      i@      i@y      i@     @o@r	   y     r@     r@y     r@     @o@N)r   r   r   r   )r   
parse_pathpath12s      r    test_wc3_examples12zTestParser.test_wc3_examples12x   s)   
 
T
 
 	*&&&%''#	   %((#	   	
 	
 	
& J
 
 	*&&&%((#	   %((#	   	
 	
 	
 	
 	
r"   c                    t           } |d          }|                     |t          t          d          t          dd          t          dd          t          dd          t          dd                                |d	          }|                     |t          t          d
          t          d
d          t          dd          t          dd          t          dd                               dS )z[
        W3C_SVG_11_TestSuite Paths
        Test multiple coordinates for V and H.
        zR   M  240.00000  56.00000    H  270.00000         300.00000 320.00000 400.00000   y      n@      L@r$   y     p@      L@r&   r%   y     r@      L@y      t@      L@y      y@      L@zS   M  240.00000  156.00000    V  180.00000         200.00000 260.00000 300.00000   y      n@     c@y      n@     f@y      n@      i@y      n@     @p@y      n@     r@N)r   r   r   r   )r   r)   path13s      r    test_wc3_examples13zTestParser.test_wc3_examples13   s-   
 
d
 
 	)%%%IY888IY888IY888IY888 		
 		
 		
 e
 
 	*&&&Jj:::Jj:::Jj:::Jj::: 		
 		
 		
 		
 		
r"   c                 |   t           } |d          }|                     |t          t          d          t          dd          t          dd          t          dd          t	          dd          t          t          dd	          d
          t          d
d          t          dd          t          dd          t	          dd
          
  
                    |d          }|                     |t          t          d          t          dd          t          dd          t          dd          t	          dd          t          t          dd	          d          t          dd          t          dd          t          dd          t	          dd          
  
                   dS )z
        W3C_SVG_11_TestSuite Paths
        Test implicit values for moveto. If the first command is 'm' it should be taken as an absolute moveto,
        plus implicit lineto.
        z   m   62.00000  56.00000    51.96152   90.00000   -103.92304         0.00000    51.96152  -90.00000   z    m    0.00000   15.00000   38.97114   67.50000   -77.91228         0.00000   38.97114  -67.50000   z  y      O@      L@r$   y̜.}\@     @b@r-   y$@     @b@y     O@      L@>   8   y      O@     Q@yb('>Y@     Pa@y
r7@     Pa@yp=
O@     Q@z   M  177.00000   56.00000    228.96152         146.00000   125.03848  146.00000    177.00000   56.00000   Z    M  177.00000  71.00000   215.97114         138.50000   138.02886  138.50000   177.00000  71.00000   Z  y      f@      L@yfNĞl@     @b@y5ctvB_@     @b@   y      f@     Q@yz1j@     Pa@y4k@a@     Pa@N)r   r   r   r   r   Point)r   r)   path14s      r    test_wc3_examples14zTestParser.test_wc3_examples14   s    
 d
 
 	($$$H,EGGG4<U   5=TVVV4HFFF5B<<h888H,GIII64   6>V   5XGGG# 	
 	
 	
,  j
 
 	)%%%I-=???,4DFFF,I???Yi9995R==y:::I-?AAA.6HJJJ.iAAAYi999 	
 	
 	
 	
 	
r"   c                 t   t           } |d          }|                     |t          t          d          t          dd          t          dd          t	          dd                                |d          }|                     |t          t          d          t          dd	          t          d	d
          t	          d
d                                |d          }|                     |t          t          d          t          dd          t          dd          t	          dd                                |d          }|                     |t          t          d          t          dd	          t          d	d
          t	          d
d                               dS )z
        W3C_SVG_11_TestSuite Paths
        'M' or 'm' command with more than one pair of coordinates are absolute
        if the moveto was specified with 'M' and relative if the moveto was
        specified with 'm'.
        zM100,120 L160,220 L40,220 zy      Y@      ^@r$   y      d@     k@r-   y      D@     k@zM350,120 L410,220 L290,220 zy     u@      ^@y     y@     k@y      r@     k@zM100,120 160,220 40,220 zzm350,120 60,100 -120,0 zNr   r   r   r   r   )r   r)   path15s      r    test_wc3_examples15zTestParser.test_wc3_examples15  s    
=>>*&&&Jj:::Ji999Yj:::	 	
 	
 	
 >??*&&&Jj:::Jj:::Zz;;;	 	
 	
 	
 ;<<*&&&Jj:::Ji999Yj:::	 	
 	
 	
 :;;*&&&Jj:::Jj:::Zz;;;	 	
 	
 	
 	
 	
r"   c                    t           } |d          }|                     |t          t          d          t          dd          t          dd          t          dd          t	          dd                                |d          }|                     |t          t          d          t          dd          t          dd          t          dd          t	          dd                                |d	          }|                     |t          t          d
          t          d
d          t          dd          t          dd          t	          dd
                                |d          }|                     |t          t          d
          t          d
d          t          dd          t          dd          t	          dd
                               dS )zl
        W3C_SVG_11_TestSuite Paths
        Test that the 'z' and 'Z' command have the same effect.
        z%M 50 50 L 50 150 L 150 150 L 150 50 zy      I@      I@r$   y      I@     b@r-   r   y     b@      I@z%M 50 50 L 50 150 L 150 150 L 150 50 Zz'M 250 50 L 250 150 L 350 150 L 350 50 Zy     @o@      I@y     @o@     b@y     u@     b@y     u@      I@z'M 250 50 L 250 150 L 350 150 L 350 50 zNr8   )r   r)   path17s      r    test_wc3_examples17zTestParser.test_wc3_examples172  s1   
 
GHH($$$HI777IZ999Ji999Yh888 		
 		
 		
 GHH($$$HI777IZ999Ji999Yh888 		
 		
 		
 IJJ)%%%IZ999Jj:::Ji999Yi999 		
 		
 		
 IJJ)%%%IZ999Jj:::Ji999Yi999 		
 		
 		
 		
 		
r"   c                 |   t           } |d          } |d          }|                     ||            |d          } |d          }|                     ||            |d          } |d          }|                     ||            |d          } |d          }|                     ||            |d	          } |d
          }|                     ||            |d          } |d          }|                     ||            |d          } |d          }|                     ||           dS )a3  
        W3C_SVG_11_TestSuite Paths
        The 'path' element's 'd' attribute ignores additional whitespace, newline characters, and commas,
        and BNF processing consumes as much content as possible, stopping as soon as a character that doesn't
        satisfy the production is encountered.
        zM 20 40 H 40zM 20 40
                 H 40zM 20 60 H 40zz
                  M
                  20
                  60
                  H
                  40
                  zM 20 80 H40zM       20,80          H    40zM 20 100 H 40#90zM 20 100 H 40zM 20 120 H 40.5 0.6zM 20 120 H 40.5.6zM 20 140 h 10 -20zM 20 140 h 10-20zM 20 160 H 40zM 20 160 H 40#90Nr   r   )r   r)   path18apath18bs       r    test_wc3_examples18zTestParser.test_wc3_examples18f  s    
*/00*
 
 	'****/00*
 
 	'****.//*ABB'****344*011'****677*455'****455*344'****011*344'*****r"   c                    t           } |d          } |d          }|                     ||            |d          } |d          }|                     ||            |d          } |d          }|                     ||            |d          } |d          }|                     ||            |d	          } |d
          }|                     ||            |d          } |d          }|                     ||            |d          } |d          }|                     ||            |d          } |d          }|                     ||            |d          } |d          }|                     ||            |d          } |d          }|                     ||            |d          } |d          }|                     ||            |d          } |d          }|                     ||            |d          } |d          }|                     ||            |d          } |d          }|                     ||            |d          } |d          }|                     ||            |d          } |d           }|                     ||           d!S )"z
        W3C_SVG_11_TestSuite Paths
        Test that additional parameters to pathdata commands are treated as additional calls to the most recent command.
        zM20 20 H40 H60zM20 20 H40 60zM20 40 h20 h20zM20 40 h20 20zM120 20 V40 V60zM120 20 V40 60zM140 20 v20 v20zM140 20 v20 20zM220 20 L 240 20 L260 20zM220 20 L 240 20 260 20 zM220 40 l 20 0 l 20 0zM220 40 l 20 0 20 0z4M50 150 C50 50 200 50 200 150 C200 50 350 50 350 150z3M50 150 C50 50 200 50 200 150 200 50 350 50 350 150z6M50, 200 c0,-100 150,-100 150,0 c0,-100 150,-100 150,0z5M50, 200 c0,-100 150,-100 150,0 0,-100 150,-100 150,0z*M50 250 S125 200 200 250 S275, 200 350 250z)M50 250 S125 200 200 250 275, 200 350 250z$M50 275 s75 -50 150 0 s75, -50 150 0z#M50 275 s75 -50 150 0 75, -50 150 0z+M50 300 Q 125 275 200 300 Q 275 325 350 300z)M50 300 Q 125 275 200 300 275 325 350 300z$M50 325 q 75 -25 150 0 q 75 25 150 0z"M50 325 q 75 -25 150 0 75 25 150 0zM425 25 T 425 75 T 425 125zM425 25 T 425 75 425 125zM450 25 t 0 50 t 0 50zM450 25 t 0 50 0 50z2M400,200 A25 25 0 0 0 425 150 A25 25 0 0 0 400 200z1M400,200 A25 25 0 0 0 425 150 25 25 0 0 0 400 200z0M400,300 a25 25 0 0 0 25 -50 a25 25 0 0 0 -25 50z/M400,300 a25 25 0 0 0 25 -50 25 25 0 0 0 -25 50Nr?   )r   r)   path19apath19bs       r    test_wc3_examples19zTestParser.test_wc3_examples19  s{   
 
*122*011'****122*011'****233*122'****233*122'****;<<*;<<'****899*677'****WXX*VWW'****H
 
 *G
 
 	'****MNN*LMM'****GHH*FGG'****NOO*LMM'****GHH*EFF'****=>>*;<<'****899*677'****UVV*TUU'****STT*RSS'*****r"   c                    t           } |d          } |d          }|                     ||            |d          } |d          }|                     ||            |d          }|                     t          d            |d          }|                     t          d            |d	          } |d
          }|                     ||            |d          }|                     t          d            |d          }|                     t          d            |d          }|                     t          d           dS )ze
        W3C_SVG_11_TestSuite Paths
        Tests parsing of the elliptical arc path syntax.
        z"M120,120 h25 a25,25 0 1,0 -25,25 zz M120,120 h25 a25,25 0 10 -25,25zz"M200,120 h-25 a25,25 0 1,1 25,25 zz M200,120 h-25 a25,25 0 1125,25 zz"M280,120 h25 a25,25 0 1,0 -25,25 zz4parse_path("""M280,120 h25 a25,25 0 6 0 -25,25 z""")z"M360,120 h-25 a25,25 0 1,1 25,25 zz5parse_path("""M360,120 h-25 a25,25 0 1 -1 25,25 z""")z#M120,200 h25 a25,25 0 1,1 -25,-25 zz"M120,200 h25 a25,25 0 1 1-25,-25 zz#M200,200 h-25 a25,25 0 1,0 25,-25 zz2parse_path("""M200,200 h-25 a25,2501 025,-25 z""")z#M280,200 h25 a25,25 0 1,1 -25,-25 zz5parse_path("""M280,200 h25 a25 25 0 1 7 -25 -25 z""")z#M360,200 h-25 a25,25 0 1,0 25,-25 zz6parse_path("""M360,200 h-25 a25,25 0 -1 0 25,-25 z""")N)r   r   assertRaises	Exception)r   r)   path20apath20bs       r    test_wc3_examples20zTestParser.test_wc3_examples20  st   
 
*EFF*CDD'****EFF*CDD'****EFF)%[\\\*EFF)%\]]]*FGG*EFF'****FGG)%YZZZ*FGG)%\]]]*FGG)%]^^^^^r"   c                    t          d          }|                     |t          t          d          t          dd          t          dd          t          dd          t          dd          t	          dd                               t          d          }|                     |t          t          d          t          ddd	d
                               t          d          }|                     |t          t          d          t          ddd
                               t          d          }|                     |t          t          d          t          ddd
                               d S )Nz+M 0 0 L 50 20 m 50 80 L 300 100 L 200 300 zr
   r   r   r   r	   zM100,200 s 150,-100 150,0r   r   r   zM100,200 t 150,0zM100,200 q 0,0 150,0)r   r   r   r   r   r   r   )r   r   s     r    test_otherszTestParser.test_others  s    BCCHH"":&&Z((Z((*j))!+ !+ 	, 	, 	, 455d:..)*j*jYY[ [	\ 	\ 	\
 +,,d:..-j*jQQS S	T 	T 	T
 /00d:..-j*jQQS S	T 	T 	T 	T 	Tr"   c                 n    t          d          }t          d          }|                     ||           dS )z)You don't need spaces before a minus-signzM100,200c10-5,20-10,30-20zM 100 200 c 10 -5 20 -10 30 -20Nr?   r   s      r    test_negativezTestParser.test_negative  s:    011677&&&&&r"   c                     t          d          }t          t          d          t          dd                    }|                     ||           dS )z'Exponents and other number format casesz!M-3.4e38 3.4E+38L-3.4E-38,3.4e-38yߌ3ǭߌ3Gy\j#'\j#'8N)r   r   r   r   r   s      r    test_numberszTestParser.test_numbers	  sR     899T.//6IK^1_1_``&&&&&r"   c                 H    |                      t          t          d           d S )NzM 100 100 L 200 200 Z 100 200)rH   
ValueErrorr   )r   s    r    test_errorszTestParser.test_errors  s!    *d,KLLLLLr"   c                 t    t          d          }|                     |                                d           d S )NzM10.236,100.184zM 10.236,100.184)r   r   d)r   paths     r    test_non_pathzTestParser.test_non_path  s7     %&&#566666r"   c                     t          t          d          t          dddddd                    }t          d          }t          d          }|                     ||           |                     ||           d S )Ny              9@r   g        r   y              9zM 0 25 A25,25 0.0 0 0 0,-25zM 0 25 A1,1 0.0 0 0 0,-25)r   r   r   r   )r   arc_path_declaredarc_path_parsedarc_path_parsed_scaleds       r    test_issue_47zTestParser.test_issue_47  s}     gGXsAqRY0Z0Z[[<==!%&A!B!B*O<<</1BCCCCCr"   c                     t          j        d          }t                              |          }|                                D ]-}t          |t                    r|                     |d           .d S )Nz"<svg><path d="M0,0 L1,0 z"/></svg>M0,0 L1,0 zioStringIOSVGparseelements
isinstancer   r   r   ssvges       r    test_svg_parsezTestParser.test_svg_parse!  sk    KABBiill 	3 	3A!T"" 3  M222	3 	3r"   c                     t          j        d          }t                              |          }|                                D ]-}t          |t                    r|                     |d           .d S )Nz<svg>
                        <g transform="scale(10,10)" vector-effect="non-scaling-stroke">
                        <path d="M0,0 L1,0 z"/>
                        </g>
                        </svg>zM0,0 L10,0 zra   rh   s       r    test_svg_parse_groupzTestParser.test_svg_parse_group(  ss    K " # #
 iill 	4 	4A!T"" 4  N333	4 	4r"   c                     t          j        d          }t                              |          }|                                D ]-}t          |t                    r|                     |d           .d S )Nz@<svg><g><path d="M0,0 L1,0 z"/><path d="M0,0 L1,0 z"/></g></svg>r`   ra   rh   s       r    test_svg_parse_group_2z!TestParser.test_svg_parse_group_23  sk    K_``iill 	3 	3A!T"" 3  M222	3 	3r"   c                    t          d          }|                     |                    d          d           |                     |                    d          d           |                     |                    d          d           |                     |                                d           t          d          }|                     |                    d          d           |                     |                    d          d           |                     |                    d          d           |                     |                                d           t          d          }|                     |                    d          d           |                     |                    d          d           |                     |                    d	          d
           |                     |                    d          d
           |                     |                                d           d S )NzM0,0r   r
   g      ?r   zM0,0ZzM0,0M1,1g\(\?gRQ?y      ?      ?)r   r   pointlength)r   	move_only
move_onlyzmove_2_placess       r    test_solo_movezTestParser.test_solo_move:  s   LL	++V444--v666++V444))++Q///']]
))!,,f555))#..777))!,,f555**,,a000Z((,,Q//888,,T22F;;;,,T22F;;;,,Q//888--//33333r"   c                    t          j        d          }t                              |          }|                                D ]H}t          |t                    r1|                     |d           |                     |j        d           Id S )NzF<svg><path d="M0,0 H10 V10 H0 z" fill-opacity="1" fill="none" /></svg>zM0,0 H10 V10 H0 znone)	rb   rc   rd   re   rf   rg   r   r   fillrh   s       r    test_fill_opacity_fill_nonez&TestParser.test_fill_opacity_fill_noneN  s    Keffiill 	2 	2A!T"" 2  $7888  111	2 	2r"   N)__name__
__module____qualname__r!   r+   r/   r6   r:   r=   rB   rF   rL   rN   rP   rR   rU   rY   r^   rl   rn   rp   rw   r{    r"   r    r   r      sW       m? m? m?^1
 1
 1
f 
  
  
D2
 2
 2
h/
 /
 /
b2
 2
 2
h'+ '+ '+R9+ 9+ 9+v_ _ _4T T T>' ' '' ' 'M M M7 7 7D D D3 3 3	4 	4 	43 3 34 4 4(2 2 2 2 2r"   r   c                   Z    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd ZdS )TestParseDisplaya  
    Tests for the parsing of displayed objects within an svg for conforming to the spec. Anything with a viewbox that
    has a zero width or zero height is not rendered. Any svg with a zero height or zero width is not rendered. Anything
    with a display="none" is not rendered whether this property comes from class, style, or direct attribute. Items with
    visibility="hidden" are rendered and returned but should be hidden by the end user.
    c                     t          j        d          }t                              |          }t	          |                                          }|                     t          |d         t                               d S )Na  <?xml version="1.0" encoding="utf-8" ?>
                        <svg width="3.0cm" height="3.0cm" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" 
                        xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
                        <g style="display:inline">
                        <line x1="0.0" x2="0.0" y1="0.0" y2="100"/>
                        </g>
                        </svg>)	rb   rc   rd   re   listrf   r   rg   
SimpleLiner   qms      r    test_svgfilezTestParseDisplay.test_svgfile_  sd    K " # # IIaLL
1R5*5566666r"   c                 f   t          j        d          }t                              |          }|                     t          |t                               t          j        d          }t                              |          }|                     t          |t                               t          j        d          }t                              |          }|                     t          |t                               |                     t          |d         t                               dS )zQ
        SVG files loaded without a valid root element crash. Issue 175.
        z<g/>z<path d="M0,0z"/>z<g><path d="M0,0z"/></g>r   N)rb   rc   rd   re   r   rg   Groupr   r   s      r    test_svgfile_no_root_issue175z.TestParseDisplay.test_svgfile_no_root_issue175k  s     K$$IIaLL
1e,,---K011IIaLL
1d++,,,K788IIaLL
1e,,---
1Q4../////r"   c                     t          j        d          }t                              |          }t	          |                                          }|                     t          |d         t                               d S )Na  <?xml version="1.0" encoding="utf-8" ?>
                        <svg width="0cm" height="3.0cm" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" 
                        xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
                        <g style="display:inline">
                        <line x1="0.0" x2="0.0" y1="0.0" y2="100"/>
                        </g>
                        </svg>r   	rb   rc   rd   re   r   rf   assertFalserg   r   r   s      r    test_svgfile_0_widthz%TestParseDisplay.test_svgfile_0_widthz  f    K " # # IIaLLAbE:6677777r"   c                     t          j        d          }t                              |          }t	          |                                          }|                     t          |d         t                               d S )Na  <?xml version="1.0" encoding="utf-8" ?>
                        <svg width="3.0cm" height="0cm" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" 
                        xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
                        <g style="display:inline">
                        <line x1="0.0" x2="0.0" y1="0.0" y2="100"/>
                        </g>
                        </svg>r   r   r   s      r    test_svgfile_0_heightz&TestParseDisplay.test_svgfile_0_height  r   r"   c                     t          j        d          }t                              |          }t	          |                                          }|                     t          |d         t                               d S )Na  <?xml version="1.0" encoding="utf-8" ?>
                        <svg width="3.0cm" height="3.0cm" viewBox="0 0 100 0" xmlns="http://www.w3.org/2000/svg" 
                        xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
                        <g style="display:inline">
                        <line x1="0.0" x2="0.0" y1="0.0" y2="100"/>
                        </g>
                        </svg>r   r   r   s      r    test_svgfile_viewbox_0_heightz.TestParseDisplay.test_svgfile_viewbox_0_height  r   r"   c                     t          j        d          }t                              |          }t	          |                                          }|                     t          |d         t                               d S )Na  <?xml version="1.0" encoding="utf-8" ?>
                        <svg width="3.0cm" height="3.0cm" viewBox="0 0 0 100" xmlns="http://www.w3.org/2000/svg" 
                        xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
                        <g style="display:inline">
                        <line x1="0.0" x2="0.0" y1="0.0" y2="100"/>
                        </g>
                        </svg>r   r   r   s      r    test_svgfile_viewbox_0_widthz-TestParseDisplay.test_svgfile_viewbox_0_width  r   r"   c                     t          j        d          }t                              |          }t	          |                                          }|                     t          |d         t                               |	                    d           t                              |d          }t	          |                                          }| 
                    t          |d         t                               d S )Na  <?xml version="1.0" encoding="utf-8" ?>
                        <svg width="3.0cm" height="3.0cm" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" 
                        xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
                        <g style="display:none">
                        <line x1="0.0" x2="0.0" y1="0.0" y2="100"/>
                        </g>
                        </svg>r   r   Tparse_display_nonerb   rc   rd   re   r   rf   r   rg   r   seekr   r   r   r   rk   s       r     test_svgfile_display_none_inlinez1TestParseDisplay.test_svgfile_display_none_inline  s    K " # # IIaLLAbE:66777	q			IIaDI11
1R5*5566666r"   c                     t          j        d          }t                              |          }t	          |                                          }|                     t          |d         t                               |	                    d           t                              |d          }t	          |                                          }| 
                    t          |d         t                               d S )Na  <?xml version="1.0" encoding="utf-8" ?>
                        <svg width="3.0cm" height="3.0cm" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" 
                        xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
                        <g display="none">
                        <line x1="0.0" x2="0.0" y1="0.0" y2="100"/>
                        </g>
                        </svg>r   r   Tr   r   r   s       r    #test_svgfile_display_none_attributez4TestParseDisplay.test_svgfile_display_none_attribute  s    K " # # IIaLLAbE:66777	q			IIaDI11
1R5*5566666r"   c                     t          j        d          }t                              |          }t	          |                                          }|                     t          |d         t                               |	                    d           t                              |d          }t	          |                                          }| 
                    t          |d         t                               dS )zd
        All children of a display="none" are excluded, even if they override that display.
        a  <?xml version="1.0" encoding="utf-8" ?>
                        <svg width="3.0cm" height="3.0cm" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" 
                        xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
                        <g display="none">
                        <line display="show" x1="0.0" x2="0.0" y1="0.0" y2="100"/>
                        </g>
                        </svg>r   r   Tr   Nr   r   s       r    test_svgfile_display_mixedz+TestParseDisplay.test_svgfile_display_mixed  s     K " # # IIaLLAbE:66777	q			IIaDI11
1R5*5566666r"   c                     t          j        d          }t                              |          }t	          |                                          }|                     t          |d         t                               |	                    d           t                              |d          }t	          |                                          }| 
                    t          |d         t                               d S )NaX  <?xml version="1.0" encoding="utf-8" ?>
                        <svg width="3.0cm" height="3.0cm" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
                        <style type="text/css">

                        .hide { 

                             display:none;

                        }

                        </style>

                        <g class="hide">
                        <line x1="0.0" x2="0.0" y1="0.0" y2="100"/>
                        </g>
                        </svg>r   r   Tr   r   r   s       r    test_svgfile_display_none_classz0TestParseDisplay.test_svgfile_display_none_class  s    K 
" 
# 
# IIaLLAbE:66777	q			IIaDI11
1R5*5566666r"   c                     t          j        d          }t                              |          }t	          |                                          }|                     t          |d         t                               |	                    d           t                              |d          }t	          |                                          }| 
                    t          |d         t                               dS )zH
        display:None is css and not svg it is case insensitive
        aX  <?xml version="1.0" encoding="utf-8" ?>
                        <svg width="3.0cm" height="3.0cm" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
                        <style type="text/css">

                        .hide { 

                             display:None;

                        }

                        </style>

                        <g class="hide">
                        <line x1="0.0" x2="0.0" y1="0.0" y2="100"/>
                        </g>
                        </svg>r   r   Tr   Nr   r   s       r    test_svgfile_display_None_classz0TestParseDisplay.test_svgfile_display_None_class  s     K 
" 
# 
# IIaLLAbE:66777	q			IIaDI11
1R5*5566666r"   c                     t          j        d          }t                              |          }t	          |                                          }|                     t          |d         t                               |	                    d           t                              |d          }t	          |                                          }|                     t          |d         t                               d S )Na  <?xml version="1.0" encoding="utf-8" ?>
                        <svg width="3.0cm" height="3.0cm" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" 
                        xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
                        <g style="visibility:hidden">
                        <line x1="0.0" x2="0.0" y1="0.0" y2="100"/>
                        </g>
                        </svg>r   r   Tr   )
rb   rc   rd   re   r   rf   r   rg   r   r   r   s       r    test_svgfile_visibility_hiddenz/TestParseDisplay.test_svgfile_visibility_hidden  s    K " # # IIaLL
1R5*55666	q			IIaDI11
1R5*5566666r"   N)r|   r}   r~   __doc__r   r   r   r   r   r   r   r   r   r   r   r   r   r"   r    r   r   W  s         
7 
7 
70 0 0
8 
8 
8
8 
8 
8
8 
8 
8
8 
8 
87 7 7$7 7 7"7 7 7(7 7 7*7 7 707 7 7 7 7r"   r   c                   H    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )TestParseDefUsez
    Tests for Def and Use within an svg file. These must work with the definitions used within the SVG spec. This means
    that use objects must be replaced with their pure tree forms as if they are children of the use flag in question.
    c                    t          j        d          }t                              |          }t	          |                                          }|D ]}	 |j        }|j        }|j        }|dk    r| 	                    d|           nP|dk    r| 	                    d|           n3|dk    r| 	                    d|           n| 	                    d|           # t          $ r Y w xY wdS )z
        The purpose of this test is to validate proper handling of
        the use element. In particular, the test checks the proper inheritance
        of properties through the shadow tree (rather than through the document
        tree).
        a_	  <?xml version="1.0" encoding="utf-8" ?>
                        <svg width="100%" height="100%" viewBox="0 0 480 360" xmlns="http://www.w3.org/2000/svg" 
                        xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
                        <defs>
                            <g fill="red" stroke="yellow" stroke-width="3">
                                <rect id="usedRect" width="20" height="20"/>
                                <circle id="usedCircle" cx="10" cy="10" r="10"/>
                                <ellipse id="usedEllipse" cx="10" cy="10" rx="10" ry="10"/>
                                <line id="usedLine" x1="0" y1="10" x2="20" y2="10"/>
                                <path id="usedPath" d="M 0 0 L 20 0 L 20 20 L 0 20 Z"/>
                                <polygon id="usedPolygon" points="0,0 20,0 20,20 0,20 0 0"/>
                                <polyline id="usedPolyline" points="0,0 20,0 20,20"/>
                                <g id="usedG">
                                    <rect width="10" height="20"/>
                                    <rect id="half_green" x="10" width="10" height="20" fill="rgb(0,128,0)"/>
                                </g>
                                <use id="usedUse" xlink:href="#usedRect"/>
                                <text id="usedText">Text</text>
                            </g>
                        </defs>
                        <g transform="translate(150, 25)">
                            <use xlink:href="#usedRect" fill="#0F0"/>
                            <use y="30" xlink:href="#usedCircle" fill="#0F0"/>
                            <use y="60" xlink:href="#usedEllipse" fill="#0F0"/>
                            <use y="90" xlink:href="#usedLine" stroke="#0F0" stroke-width="2"/>
                            <use y="120" xlink:href="#usedPolyline" stroke="#0F0" stroke-width="2" fill="none"/>
                            <use y="150" xlink:href="#usedPolygon" fill="#0F0"/>
                            <use y="180" xlink:href="#usedPath" fill="#0F0"/>
                            <use x="180" y="0" xlink:href="#usedG" fill="#0F0"/>
                            <use x="180" y="30" xlink:href="#usedUse" fill="#0F0"/>
                            <use y="260" xlink:href="#usedText" fill="#0F0"/>
                        </g>
                        </svg>
half_greenz#008000usedLinez#0F0usedPolylineN)rb   rc   rd   re   r   rf   idrz   stroker   AttributeError)r   r   r   elementidentrz   r   s          r    test_struct_use_01z"TestParseDefUse.test_struct_use_01&  s    K  "  #  #B IIaLL 	 	G
| L(($$Y5555j(($$VV4444n,,$$VV4444$$VT222!   	 	s   BC
C%$C%c                     t          j        d          }t                              |          }t	          |                                          }|                     t          |          d           d S )Na  <?xml version="1.0" encoding="utf-8" ?>
                        <svg>
                            <defs>
                                <g>
                                    <rect x="100" y="100" width="100" height="100" />
                                    <circle cx="100" cy="100" r="100" />
                                </g>
                            </defs>
                        </svg>r   rb   rc   rd   re   r   rf   r   lenr   s      r    test_struct_defs_ignoredz(TestParseDefUse.test_struct_defs_ignoreda  s`    K " # # IIaLLQ#####r"   c                     t          j        d          }t                              |          }t	          |                                          }|                     t          |          d           d S )Nz<?xml version="1.0" encoding="utf-8" ?>
                        <svg>
                        <use href="garbage_address"/>
                        </svg>   r   r   s      r    test_struct_use_unlinkedz(TestParseDefUse.test_struct_use_unlinkedo  s`    K " # # IIaLLQ#####r"   c                     dd l }ddlm}m  |j        d          }|                    |                              fd          D ]%}|                     t          |                     &d S )Nr   )rd   r   a;  <svg version="1.0" xmlns="http://www.w3.org/2000/svg"
         width="500" height="500" viewBox="0 0 500 500" preserveAspectRatio="xMidYMid meet">
         <path d="M50 150 C50 50 200 50 200 150 C200 50 350 50 350 150 z"/>
         <path d="M350 250 C50 50 200 50 200 150 C200 50 350 50 350 150 z"/> 
        </svg>c                 $    t          |           S N)rg   )elr   s    r    <lambda>zBTestParseDefUse.test_parse_conditional_issue_114.<locals>.<lambda>  s    JrSWDXDX r"   conditional)	rb   svgelementsrd   r   rc   re   rf   r   type)r   rb   rd   svg_strri   r   s        @r     test_parse_conditional_issue_114z0TestParseDefUse.test_parse_conditional_issue_114x  s    			))))))))"+    7##,,9X9X9X9X,YY 	, 	,AT!WWd++++	, 	,r"   c                 "   t          j        d          }t                              |          }t	          |                    d                     d         }|                     |t                     |                     |j	        d           dS )
        Test to verify that a CSS stylesheet variable that does not end with a `;` is properly combined with the
        per attribute and inherited values.
        a  <?xml version="1.0" encoding="utf-8" ?>
                        <svg width="3.0cm" height="3.0cm" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" 
                        xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
                        <style type="text/css" >
                          <![CDATA[
                            line {
                               stroke: #006600
                            }
                          ]]>
                        </style>
                        <g style="stroke:red">
                        <line x1="0.0" x2="0.0" y1="0.0" y2="100" style="stroke:blue"/>
                        </g>
                        </svg>c                 ,    t          | t                    S r   )rg   Shaper   s    r    r   z=TestParseDefUse.test_style_concat_issue_180.<locals>.<lambda>  s    jU6K6K r"   r   r   blueN)
rb   rc   rd   re   r   rf   assertIsInstancer   r   r   r   r   r   lines       r    test_style_concat_issue_180z+TestParseDefUse.test_style_concat_issue_180  s    
 K " # # IIaLLAJJ+K+KJLLMMaPdJ///f-----r"   c                 "   t          j        d          }t                              |          }t	          |                    d                     d         }|                     |t                     |                     |j	        d           dS )r   a{  <?xml version="1.0" encoding="utf-8" ?>
                        <svg width="3.0cm" height="3.0cm" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" 
                        xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
                        <text font-weight="bolder"> Bolder would crash. </text>
                        </svg>c                 ,    t          | t                    S r   )rg   Textr   s    r    r   z:TestParseDefUse.test_font_bolder_parsing.<locals>.<lambda>  s    jT6J6J r"   r   r   bolderN)
rb   rc   rd   re   r   rf   r   r   r   font_weightr   s       r    test_font_bolder_parsingz(TestParseDefUse.test_font_bolder_parsing  s    
 K " # #
 IIaLLAJJ+J+JJKKLLQOdD))))844444r"   c                    t          j        d          }t                              |d          }t	          |                                          }|                     dt          |                     |                     t          |d         t                               |                     d|d                                                    d S )Na|  <?xml version="1.0" encoding="utf-8" ?>
                        <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" 
                        xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
                        <path d="M10,10 L20,20 L NaN NaN"/>
                        <path d="M20,10 L20,20"/>
                        </svg>stopon_errorr   r   zM 10,10 L 20,20)rb   rc   rd   re   r   rf   r   r   r   rg   r   rW   r   blockr   r   s       r    test_parse_error_issue_217_stopz/TestParseDefUse.test_parse_error_issue_217_stop  s     " # # IIefI--CFF###
1R5$//000*AbEGGII66666r"   c                 l    t          j        d          |                     t          fd           d S )N  <?xml version="1.0" encoding="utf-8" ?>
                                <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" 
                                xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink">
                                <path d="M10,10 L20,20 L NaN NaN"/>
                                <path d="M20,10 L20,20"/>
                                </svg>c                  <    t                                d          S )Nraiser   )rd   re   )r   s   r    r   zCTestParseDefUse.test_parse_error_issue_217_raises.<locals>.<lambda>  s    ciii.P.P r"   )rb   rc   rH   rT   )r   r   s    @r    !test_parse_error_issue_217_raisesz1TestParseDefUse.test_parse_error_issue_217_raises  sA     * + + 	*&P&P&P&PQQQQQr"   c                     t          j        d          }t                              |          }t	          |                                          }|                     dt          |                     d S )Nr      r   r   s       r    !test_parse_error_issue_217_ignorez1TestParseDefUse.test_parse_error_issue_217_ignore  sb     * + + IIeCFF#####r"   N)r|   r}   r~   r   r   r   r   r   r   r   r   r   r   r   r"   r    r   r      s         
9 9 9v$ $ $$ $ $, , ,. . .05 5 57 7 7R R R
$ 
$ 
$ 
$ 
$r"   r   )rb   unittestr   TestCaser   r   r   r   r"   r    <module>r      s    				     M	2 M	2 M	2 M	2 M	2" M	2 M	2 M	2`F7 F7 F7 F7 F7x( F7 F7 F7Rm$ m$ m$ m$ m$h' m$ m$ m$ m$ m$r"   