
    HR-et                         d dl Z d dlZd dlmZ d dlmZmZmZmZ d dl	m
Z
 d dlmZmZ d dlmZ d dlmZ d Zd	 Zd
 Zd Zd Zd Zd Zd ZdS )    N)tree)W07W08W21W41)parse)ResourceVOTableFile)get_pkg_data_filename)AstropyDeprecationWarningc                      ddi} t          j        d dd          }t          j        t                    5  t          j        d||            d d d            d S # 1 swxY w Y   d S )Nverify	exception	astroyear1)name	arraysizeX2100)r   Fieldpytestraisesr   check_astroyear)configfields     Blib/python3.11/site-packages/astropy/io/votable/tests/tree_test.pytest_check_astroyear_failr      s    $FJt+===E	s		 5 5WeV4445 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5s   AA Ac                      ddi} t          j        t                    5  t          j        dd|            d d d            d S # 1 swxY w Y   d S )Nr   r   *   foo)r   r   r   r   check_string)r   s    r   test_string_failr!      s    $F	s		 - -"eV,,,- - - - - - - - - - - - - - - - - -s   AA	Ac                  D   t          j                    } t          j                    }| j                            |           t          j        |           }|j                            |           |j                            t          j	        | ddd          g           d S )NTestfloatmag)r   datatypeunit)
r   r
   r	   	resourcesappendTabletablesfieldsextendr   )votableresourcetables      r   test_make_Fieldsr1      s      G}HX&&& JwEO5!!!	L	G&7	G	G	GH        c                     t          t          d                    } | j        d         dk    sJ t          j        | j                  dk    sJ t          t          d                    } | j        d         dk    sJ t          j        | j                  dk    sJ t          t          d                    } | j        d         dk    sJ t          j        | j                  dk    sJ t          t          d	                    } | j        d         d
k    sJ t          j        | j                  dk    sJ t          t          d                    } | j        d         dk    sJ t          j        | j                  dk    sJ d S )Nzdata/irsa-nph-error.xmlversion1.0cdszdata/names.xml1.1zdata/gemini.xml1.2zdata/binary2_masked_strings.xml1.3zdata/timesys.xml1.4vounit)r   r   _configr   _get_default_unit_format)datas    r   test_unit_formatr?   *   s   &'@AABBD<	"e++++(66%????&'78899D<	"e++++(66%????&'899::D<	"e++++(66%????&'HIIJJD<	"e++++(66%????&'9::;;D<	"e++++(66(BBBBBBr2   c                  F   d} t          j        t                    5  t          t	          j        |           d           ddd           n# 1 swxY w Y   d}t          t	          j        |          d           d}t          t	          j        |          d           dS )z
    A version 1.4 VOTable must use the same namespace as 1.3.
    (see https://www.ivoa.net/documents/VOTable/20191021/REC-VOTable-1.4-20191021.html#ToC16).
    s   <?xml version="1.0" encoding="utf-8"?>
        <VOTABLE version="1.4" xmlns="http://www.ivoa.net/xml/VOTable/v1.4"
                               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
          <RESOURCE/>
        </VOTABLE>
    r   r   Ns   <?xml version="1.0" encoding="utf-8"?>
        <VOTABLE version="1.4" xmlns="http://www.ivoa.net/xml/VOTable/v1.3"
                               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
          <RESOURCE/>
        </VOTABLE>
    s   <?xml version="1.0" encoding="utf-8"?>
        <VOTABLE version="1.3" xmlns="http://www.ivoa.net/xml/VOTable/v1.3"
                               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
          <RESOURCE/>
        </VOTABLE>
    )r   warnsr   r   ioBytesIO)bad_namespacegood_namespace_14good_namespace_13s      r   test_namespace_warningrH   <   s    
M 
c		 = =bj''<<<<= = = = = = = = = = = = = = = 
"*&
'
'<<<< 
"*&
'
'<<<<<<s   $AAAc                     t          j        t                    5  t          d           ddd           n# 1 swxY w Y   dD ]} t          |            dD ]E} t          j        t
          d          5  t          |            ddd           n# 1 swxY w Y   Ft                      }dD ]	} | |_        
dD ]<} t          j        t
          d	          5  | |_        ddd           n# 1 swxY w Y   =d
}d}d}dD ]1}t          t          j	        ||z   |z   |z   |z             d           2t          t          j	        |dz   |z   dz   |z             d           dD ]b}t          j        t                    5  t          t          j	        ||z   |z   |z   |z             d           ddd           n# 1 swxY w Y   cdS )a  
    VOTableFile.__init__ allows versions of '1.0', '1.1', '1.2', '1.3' and '1.4'.
    The '1.0' is curious since other checks in parse() and the version setter do not allow '1.0'.
    This test confirms that behavior for now.  A future change may remove the '1.0'.
    r5   r4   N)r7   r8   r9   r:   )z0.92.0z3should be in \('1.0', '1.1', '1.2', '1.3', '1.4'\).)match)r5   rK   z5supports VOTable versions '1.1', '1.2', '1.3', '1.4'$s8   <?xml version="1.0" encoding="utf-8"?><VOTABLE version="s*   " xmlns="http://www.ivoa.net/xml/VOTable/vsM   " xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><RESOURCE/></VOTABLE>)s   1.1s   1.2   1.3r   rA   s   1.4rM   )s   1.0s   2.0)r   rB   r   r
   r   
ValueErrorr4   r   rC   rD   r   )r4   votbeginmiddleendbversions         r   test_versionrT   [   s4    
/	0	0 # #E""""# # # # # # # # # # # # # # #/ % %G$$$$$! ) )]T
 
 
 	) 	) ((((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) --C/  ! " "]V
 
 
 	" 	" "CK	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" HE:FX 
 - 
 
Jux'&08;cABB;	
 	
 	
 	
 	
 
"*UV^f,v5;
<
<[QQQQ %  \# 	 	
58+f4x?#EFF"   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 sB   7;;6BB	B	C,,C0	3C0	>0F::F>	F>	c                 >   t          |           }|j                            t                                 t	          j                    }|                    |           |                    d           |                                }|	                    d          }|S )NrJ   r   zutf-8)
r
   r(   r)   r	   rC   rD   to_xmlseekreaddecode)r4   votable_file	xml_bytesbstringss        r   votable_xml_stringr^      s    w///L!!(**---
I	"""NN1nnGwAHr2   c                      t          d          } d| v sJ d| v sJ t          d          } d| v sJ d| v sJ t          d          } d| v sJ 	 d
| v sJ t          d          } d| v sJ 	 d| v sJ d S )Nr7   z,xmlns="http://www.ivoa.net/xml/VOTable/v1.1"zDxsi:noNamespaceSchemaLocation="http://www.ivoa.net/xml/VOTable/v1.1"r8   z,xmlns="http://www.ivoa.net/xml/VOTable/v1.2"zDxsi:noNamespaceSchemaLocation="http://www.ivoa.net/xml/VOTable/v1.2"r9   z,xmlns="http://www.ivoa.net/xml/VOTable/v1.3"z9xsi:schemaLocation="http://www.ivoa.net/xml/VOTable/v1.3 z0http://www.ivoa.net/xml/VOTable/VOTable-1.3.xsd"r:   z0http://www.ivoa.net/xml/VOTable/VOTable-1.4.xsd")r^   )xmls    r   test_votable_tagra      s    
U
#
#C9S@@@@QUXXXXX
U
#
#C9S@@@@QUXXXXX
U
#
#C9S@@@@F=DDDD
U
#
#C9S@@@@F=DDDDDDr2   )rC   r   astropy.io.votabler   astropy.io.votable.exceptionsr   r   r   r   astropy.io.votable.tabler   astropy.io.votable.treer	   r
   astropy.utils.datar   astropy.utils.exceptionsr   r   r!   r1   r?   rH   rT   r^   ra    r2   r   <module>ri      s&   				  # # # # # # < < < < < < < < < < < < * * * * * * 9 9 9 9 9 9 9 9 4 4 4 4 4 4 > > > > > >5 5 5- - -  C C C$= = =>/ / /d	 	 	E E E E Er2   