
    ]jD                     `    d dl Z d dlZd dlZd dlZd dlmZ d dlT  G d dej                  ZdS )    N)
ParseError)*c                   J    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 )TestElementWritec                     t          j        d          }t                              |d          }t	          |                                           d S )Na  
            <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="360pt" height="360pt" viewBox="0 0 360 360" version="1.1">'
            <g id="mygroup">
            <path style="fill:none;stroke-width:0.004;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 0.00199653 0 L 0.00199653 1 M 0.0220052 0 L 0.0220052 1 M 0.042003 0 L 0.042003 1 M 0.0620009 0 L 0.0620009 1 M 0.0819987 0 L 0.0819987 1 M 0.101997 0 L 0.101997 1 M 0.122005 0 L 0.122005 1 M 0.142003 0 L 0.142003 1 M 0.162001 0 L 0.162001 1 M 0.181999 0 L 0.181999 1 M 0.201997 0 L 0.201997 1 M 0.222005 0 L 0.222005 1 M 0.242003 0 L 0.242003 1 M 0.262001 0 L 0.262001 1 M 0.281999 0 L 0.281999 1 M 0.301997 0 L 0.301997 1 M 0.322005 0 L 0.322005 1 M 0.342003 0 L 0.342003 1 M 0.362001 0 L 0.362001 1 M 0.381999 0 L 0.381999 1 M 0.401997 0 L 0.401997 1 M 0.422005 0 L 0.422005 1 M 0.442003 0 L 0.442003 1 M 0.462001 0 L 0.462001 1 M 0.481999 0 L 0.481999 1 M 0.501997 0 L 0.501997 1 M 0.522005 0 L 0.522005 1 M 0.542003 0 L 0.542003 1 M 0.562001 0 L 0.562001 1 M 0.581999 0 L 0.581999 1 M 0.601997 0 L 0.601997 1 M 0.622005 0 L 0.622005 1 M 0.642003 0 L 0.642003 1 M 0.662001 0 L 0.662001 1 M 0.681999 0 L 0.681999 1 M 0.701997 0 L 0.701997 1 M 0.722005 0 L 0.722005 1 M 0.742003 0 L 0.742003 1 M 0.762001 0 L 0.762001 1 M 0.781999 0 L 0.781999 1 M 0.801997 0 L 0.801997 1 M 0.822005 0 L 0.822005 1 M 0.842003 0 L 0.842003 1 M 0.862001 0 L 0.862001 1 M 0.881999 0 L 0.881999 1 M 0.901997 0 L 0.901997 1 M 0.922005 0 L 0.922005 1 M 0.942003 0 L 0.942003 1 M 0.962001 0 L 0.962001 1 M 0.981999 0 L 0.981999 1 " transform="matrix(360,0,0,360,0,0)"/>
            </g>
            </svg>
            F)reify)ioStringIOSVGparseprint
string_xml)selfqsvgs      J/home/agentuser/manim-venv/lib/python3.11/site-packages/test/test_write.py
test_writezTestElementWrite.test_write   sM    K  iii''cnn    c                 r    t                      }|                     |                                d           d S )Nz<g />)GroupassertEqualsr   )r   gs     r   test_write_groupz!TestElementWrite.test_write_group   s/    GG!,,..'22222r   c                    t          ddddd          }|                     |                                d           |dz  }|                     |                                d           |                                 |                     |                                d           t	          |          }|                     |                                d	           d S )
N1in3inz5%)rx)zI<rect rx="0.15in" x="1in" y="1in" ry="0.15in" width="3in" height="3in" />zI<rect height="3in" rx="0.15in" ry="0.15in" width="3in" x="1in" y="1in" />zscale(3))z<rect rx="0.15in" x="1in" y="1in" ry="0.15in" width="3in" height="3in" transform="matrix(3.000000, 0.000000, 0.000000, 3.000000, 0.000000, 0.000000)" />z<rect height="3in" rx="0.15in" ry="0.15in" transform="matrix(3.000000, 0.000000, 0.000000, 3.000000, 0.000000, 0.000000)" width="3in" x="1in" y="1in" />)zI<rect rx="0.45in" x="3in" y="3in" ry="0.45in" width="9in" height="9in" />zI<rect height="9in" rx="0.45in" ry="0.45in" width="9in" x="3in" y="3in" />)z<path rx="5%" d="M 3.45,3 L 11.55,3 A 0.45,0.45 0 0,1 12,3.45 L 12,11.55 A 0.45,0.45 0 0,1 11.55,12 L 3.45,12 A 0.45,0.45 0 0,1 3,11.55 L 3,3.45 A 0.45,0.45 0 0,1 3.45,3 Z" />z<path d="M 3.45,3 L 11.55,3 A 0.45,0.45 0 0,1 12,3.45 L 12,11.55 A 0.45,0.45 0 0,1 11.55,12 L 3.45,12 A 0.45,0.45 0 0,1 3,11.55 L 3,3.45 A 0.45,0.45 0 0,1 3.45,3 Z" rx="5%" />)RectassertInr   r   Pathr   rs     r   test_write_rectz TestElementWrite.test_write_rect   s    ue555LLNN	
 	
 	
 	
ZLLNN	
 	
 	
 	
			LLNN	
 	
 	
 GGLLNN	
 	
 	
 	
 	
r   c                     t          d          }|dz  }|                     |                                d           |                                 |                     |                                d           d S )NzM0,0zzzzztranslate(5,5)zi<path d="M 0,0 z z z z" transform="matrix(1.000000, 0.000000, 0.000000, 1.000000, 5.000000, 5.000000)" />z<path d="M 5,5 z z z z" />)r    assertEqualr   r   r!   s     r   test_write_pathz TestElementWrite.test_write_path?   st    	LLNNw	
 	
 	
 	
			)EFFFFFr   c                     t          ddd          }t                              t          j        |                                                    }|                     ||           d S )N   noneyellow)r"   strokefill)Circler   r   r	   r
   r   r%   r   cr   s      r   test_write_circlez"TestElementWrite.test_write_circleI   sU    QvH555IIbk!,,..1122Ar   c                     t          ddd          }t                              t          j        |                                                    }|                     ||           d S )N      zcornflower blue)r   ryr,   )Ellipser   r   r	   r
   r   r%   r.   s      r   test_write_ellipsez#TestElementWrite.test_write_ellipseN   sV    qQ%6777IIbk!,,..1122Ar   c                     t          dddddd          }t                              t          j        |                                                    }|                     ||           d S )Nr   
   r(      linez
light grey)x1x2y1y2idr,   )
SimpleLiner   r   r	   r
   r   r%   r.   s      r   test_write_linez TestElementWrite.test_write_lineS   s[    !qQ6MMMIIbk!,,..1122Ar   c           	         d}|                      t          j        |           t          j        |          }t          ddd          }|                    t          ddddd                     |                    |d	d	
           dS )z
        Tests pathlib.Path file saving. This is permitted by the xml writer but would crash see issue #227

        This also provides an example of pretty-print off and short_empty_elements off (an xml writer option).

        z
myfile.svg0 0 1000 100010mmviewportheightwidth10%80%redr,   F)prettyshort_empty_elementsN)	
addCleanuposremovepathlibr    r   appendr   	write_xml)r   file1filer   s       r   test_write_pathlib_issue_227z-TestElementWrite.test_write_pathlib_issue_227X   s     	5)))|E""?6HHH

4ueU???@@@d5uEEEEEr   c           	          d}|                      t          j        |           t          ddd          }|                    t          ddddd                     |                    |d	d
           dS )z
        Tests filename file saving. This is permitted by the xml writer but would crash see issue #227

        This also provides an example short_empty_elements off, utf-8 encoding.

        zmyfile-f.svgrC   rD   rE   rI   rJ   rK   rL   Fzutf-8)rN   encodingNrO   rP   rQ   r   rS   r   rT   r   rU   r   s      r   test_write_filenamez$TestElementWrite.test_write_filenamef   sv     	5)))?6HHH

4ueU???@@@e%'JJJJJr   c           	          d}|                      t          j        |           t          ddd          }|                    t          ddddd                     |                    |d	
           dS )z
        Tests pathlib.Path file saving. This is permitted by the xml writer but would crash see issue #227

        This also provides an example of xml_declaration=True.

        zmyfile-f.svgzrC   rD   rE   rI   rJ   rK   rL   T)xml_declarationNrZ   r[   s      r   test_write_filename_svgzz)TestElementWrite.test_write_filename_svgzs   st      	5)))?6HHH

4ueU???@@@eT22222r   N)__name__
__module____qualname__r   r   r#   r&   r0   r6   rA   rW   r\   r_    r   r   r   r   
   s        
  
  
 3 3 3 
  
  
DG G G  
  
  
F F FK K K3 3 3 3 3r   r   )	r	   rP   rR   unittestxml.etree.ElementTreer   svgelementsTestCaser   rc   r   r   <module>rh      s    				 				   , , , , , ,    t3 t3 t3 t3 t3x( t3 t3 t3 t3 t3r   